I uploaded a screen recording to
youtube to show the frontend editing functionality of ConfigBox, our in-house developed
product configurator for Joomla. There, you log into the frontend and simply doubleclick anything to edit it via AJAX. Short strings like titles get edited in the same style as the text looks like, html text is edited with the user's html editor. This shouldn't be advertisement for my component, but rather show some features easily done with the extended framework on which the component is based on (for the framework library, see my recent blog post).
The idea is simple. Extract the HTML editor parameters set in the user editor plugin, invoke the editor dynamically with JavaScript instead of JEditor, do some JavaScript that fires the editor or any form element on double click on the content and have your backend models respond to a request with JSON data. That way, all your validation and storage methods already implemented can be used to do the backend business.
Doing it was not all that straight forward...
1st extract the HTML editor parameters:
There is a nice onInit method in each editor plugin file, that puts stuff like the js includes in the head, put's together the parameters for the editor and so on. Well, I'm only interested in the parameters and would need it in JSON format to invoke the editor manually later on. So I copied the method's code (for tinyMCE and JCE so far) and rewrote it so it returns a JSON object with my dear params. With an JDocument addScriptDeclaration I had the params in the DOM for later. You can have that
script (Updated with MIT/GPL license block) if you need it to save yourself the hassle.
2nd do some javascript that loads the form element:
That would be quite individual for each component, the rough idea behind it is to bind doubleclick events to certain elements with a certain class or ID and have the callback see what kind of element it is and do the rest.
3rd receive the data and save it:
The only thing you have to do here is loading the record first, replace the field/fields changed and then save the record. Otherwise your check() method will complain or your record will be empty except the field you changed.
You need to be a member of All Together, As A Whole to add comments!
Join All Together, As A Whole