Multiple fckEditor instance in same page


Many times we want to use multiple instances of FckEditor on same page. You may want to specify different attribute with <liferay-ui:input-editor> tag  like name , attribute , initMethod , onChangedMethod.

If you directly use <liferay-ui:input-editor> this tag. Then default behaviour will be some thing like this
initMethod -- <portlet:namespace>initEditor
function <portlet:namespace>initEditor() { return "Hello" ; }
So above fckEditor will be loaded with the predefine text "Hello".

How to get content for fckEditor ?
var fckEditorContent = window.<portlet:namespace>editor.getHTML();
Same way if we want to use another fckEditor on same page then specify attribute like this .
<liferay-ui:input-editor height="200" initmethod="initHeaderFckEditor" name="headerFckEditor" width="500">
Specify initMethod in this way.
function initHeaderFckEditor(){ return "Hello world" ; }
Get content
var customValue = window.headerFckEditor.getHTML();

Next PostNewer Post Previous PostOlder Post Home