I am loading a section of a page with an ajax call but the editor in that section is not visible when it is loaded via ajax. If I access "mysite.com/index.php?mod=page3" directly, without any ajax calls, the editor shows fine.
I will try to simplify as best I can the workings of the CMS (it is the Flatnux CMS). Here are the details of the situation:
The "pages" of my CMS correspond to the central section of the page, which is loaded according to the querystring (?mod=pagex). I have a folder for these pages: "/sections/page1.php", "/sections/page2.php", etc.
In "/sections/page3.php" I have an editor instance:
If I make an ajax call to "/sections/page3.php" and load the results into a div in the center of the page on index.php, everything shows fine except the ckeditor. All the javascript is executed fine. If I inspect the elements with the Chrome inspector I see that "<div id='emailbody'>" has received "visibility:none", but there is no ckeditor.
If instead I load the page from the querystring (index.php?mod=page3), and page3.php is php-included within that same div, then the ckeditor loads just fine.
Could it be because document.ready doesn't work the same way in an ajax call? The rest of the javascript code in document.ready works just fine... Any ideas what could be going on?
I will try to simplify as best I can the workings of the CMS (it is the Flatnux CMS). Here are the details of the situation:
The "pages" of my CMS correspond to the central section of the page, which is loaded according to the querystring (?mod=pagex). I have a folder for these pages: "/sections/page1.php", "/sections/page2.php", etc.
In "/sections/page3.php" I have an editor instance:
<!-- jquery is already loaded by the CMS theme from the Google repository... --> <script type='text/javascript' src='/include/extra/fck3/ckeditor/ckeditor.js'></script> <script type='text/javascript' src='/include/extra/fck3/ckeditor/adapters/jquery.js'></script> <script type="text/javascript"> $(document).ready(function(){ floptwidth = $("#floptdiv").width()-20; $("#emailbody").ckeditor({width:floptwidth}); }); </script> <?php echo "<div id='emailbody'></div>"; ?>
If I make an ajax call to "/sections/page3.php" and load the results into a div in the center of the page on index.php, everything shows fine except the ckeditor. All the javascript is executed fine. If I inspect the elements with the Chrome inspector I see that "<div id='emailbody'>" has received "visibility:none", but there is no ckeditor.
If instead I load the page from the querystring (index.php?mod=page3), and page3.php is php-included within that same div, then the ckeditor loads just fine.
Could it be because document.ready doesn't work the same way in an ajax call? The rest of the javascript code in document.ready works just fine... Any ideas what could be going on?
Re: editor not visible on pages loaded via ajax
Re: editor not visible on pages loaded via ajax
Ok I have made a test case: http://consultapg33.altervista.org/cked ... xtest.html
And I think I see what the problem is. When inspecting the page in Google Chrome, I see that these are added to the head:
But my ckeditor files are all located in "/include/extra/fck3/ckeditor/".
So the ckeditor jquery adapter is looking for the files in the wrong place.
Is there a way of specifying the correct path?
Re: editor not visible on pages loaded via ajax
Seeing what the problem was I searched on google and found the answer right away:
http://docs.cksource.com/CKEditor_3.x/D ... ditor_Path
It's working fine now! So when loading it on a page that is loaded via AJAX it is necessary to specity the basepath variable before loading the cdeditor.js script like so:
Re: editor not visible on pages loaded via ajax
Great, thanx for sharing!