Search code examples
jqueryloadpage-refresh

Jquery .load need page refresh but but also return false - help


Hi folks this is prob quiet simple but not sure how to do it.

I am loading pages into a div a simple like this:

$('.pageLink').click(function() {
var pagetoload = ($(this).attr('href').substring(5));
$('#adminArea').load(pagetoload+'.php');
return false;
});

That works no probs at all. Only thing is that I am using CKEditor on "several"of the loaded pages and to display CKEditor in all the pages it seems to require a page refresh I know this is TOTALLY wrong and does not work (obviously) but it gives you an idea of what is needed, just how do you achieve it - if it is possible.

$('.pageLink').click(function() {
var pagetoload = ($(this).attr('href').substring(5));
return true;
$('#adminArea').load(pagetoload+'.php');
return false;
});

any ideas? - thanks in advance


Solution

  • When implementing CKE you have to use a code segment like below.

    CKEDITOR.replace( 'editor1' );
    

    While you are accessing from Ajax this is called before the editor is attached to the page. You can try one thing. After loading your ajax content, then call the CKEDITOR.replace() function on a specified control again. This might solve your problem.

    [EDIT]

    $('#adminArea').load(pagetoload+'.php');
    CKEDITOR.replace( 'EDITOR' );
    

    [EDIT 2]

    $('#adminArea').load(pagetoload+'.php', function() {
      CKEDITOR.replace( 'EDITOR' );
    });