1

I am using Joomla 1.7 and I am made a custom button (editor-xtd plugin) that I want to insert some string into the current editor content.

Like in the Readmore button. I have searched through the Readmore code and found :

$js = "
    function insertReadmore(editor) {
        var content = $getContent
        if (content.match(/<hr\s+id=(\"|')system-readmore(\"|')\s*\/*>/i)) {
            alert('$present');
            return false;
        } else {
            jInsertEditorText('<hr id=\"system-readmore\" />', editor);
        }
    }
";

Now when I try to call jInsertEditorText, I seem to get an error that it's missing.

Some forum suggested I import mootools.js, but that didn't seem to do the trick.

Where can I find it or is there some other approach?

mickmackusa
  • 43,625
  • 12
  • 83
  • 136
eric.itzhak
  • 15,752
  • 26
  • 89
  • 142

2 Answers2

1

I know that this answer comes in very very late for this question, but it appears on the first page of Google and remains unanswered, so here it is:

Things have changed since 2012 and editors now must implement the following two functions:

// Set value
if (typeof Joomla.editors.instances["jform_editor_name"] !== "undefined") {
  Joomla.editors.instances["jform_editor_name"].setValue(ourHTML);
}

// Get value
var text = Joomla.editors.instances["jform_editor_name"].getValue();
mavrosxristoforos
  • 3,573
  • 2
  • 25
  • 40
1

jInsertEditorText is defined by the editor, not in mootools. Try using TinyMCE editor or JCE, both support it fully.

Ric Z
  • 11
  • 1