The story goes like this:
- I have my own component that let user to edit stuff using Joomla built in editor and I am not working with form.
The code would be rather trivial except that I load the stuff that I want to put into the editor to start with, not when I creating page, but only when user clicked some button.
Since this editing mode is not so common to use, this save the size of the HTML data transferred , improve loading time etc.
So when user does clicks a button I execute JS function (onclick) that post request to joomla, get the results and put it in textbox assigned for the editor.
Unfortunately this does not work, of course if I fill the textbox before calling display() on the editor - it works fine, but as I said I need it a way later (the editor windows is displayed when page is build but hidden).
The work around solution I found on net works, but sounds fishy , I call :
Code: Select all
var activeEditor = tinyMCE.get('content');
And it does work, however I find it "funny" that it actually works because in my Joomla config I set JCE not TinyMCE as an editor and indeed editor displayed IS JCE.
So first I find it strange that it works at all, second - let's say JCE derived somehow from tinyMCE , but what will happen if I switch to some other editor?
Personally I prefer to work with JEditor object as it more generic, but how I can access it from JS ?
The other solution I tried (and it works too) is to put the JS function in question into php as a text to generate and add it using JFactory::getDocument()->addScriptDeclaration(), there I can use JEditor::getEditor() to be generic, but all this textual js code looks really ugly Especially when most of the js stuff is located in .js file...
Not to mention the fact that I do need to pass parameters to this function to go as first parameter to setContext() since there are several possible places I want to edit tied to different textpoxes and buttons and I can't pass JS parameters to PHP generated coed, so I need to create several variants of this function - looks really ugly
So does anyone have any suggestion how to get to generic JEditor object from JS ?
And another thing while on the same topic, when generating my calls in php using JEditor::getEditor()->setContext(..) I noticed that in resulting HTML it translates to WFEditor.setContext(..)
So my question is this WFEditor a generic JEditor object I seek or it just specific for JCE ?