views:

24

answers:

1

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

A: 

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' );
});
Muneer
Hi Muneer, thanks for this but I am calling CKEDITOR.replace( 'editor1' ); on each page, could it be I am using the same name/class?
.load is not synchronous so here you call the .replace before the dynamic content has loaded. He would need to exectue the .replace inside the .load callback.
redsquare
Yes russp, as redsqure told, it might work if you call the replace in the callback. I have put a second EDIT. please check that also,** using same class would not be a problem for this.
Muneer
This seems like "long running" question everywhere, sadly all the solutions only every seem to "partly" work Muneer your A is the closest as it does work, BUT only for the first viewing so you can "test" it shows on all the pages, but go back a second time and it doesn't show - and BTW it is destroy not replace - CKEDITOR.destroy( 'EDITOR' );
what you mean by go back second time? Viewing Page history to back?
Muneer