Get content of editor - error

Added by Dave Jansen about 1 year ago

I'm trying to get the contents of my editor following the docs (http://elrte.org/redmine/projects/elrte/wiki/JavaScript_API_EN).
I nicely get a editor when i call my page, but when i want to get my contents, i get the following error in firebug

$("#activity_descr").elrte is not a function

This id has an editor, and i can call the original content by $("#activity_descr").val(); , but calling elrte('val'); on the element is results in the error.
I put my elrte init code in the $().ready(function(), and my code to call the content outside of this.


Replies (9)

RE: Get content of editor - error - Added by Troex Nevelin about 1 year ago

Can you please post here how you init elRTE? maybe you are trying to access elRTE before it is created on load?

RE: Get content of editor - error - Added by Dave Jansen about 1 year ago

            $().ready(function() {

            var opts = {
                lang     : 'en',
                height   : 100,
                width    : 400,
                toolbar  : 'foxi',
                absoluteURLs: false,
                resizable :true,
                allowSource :true,
        styleWithCSS : false,
                fmOpen : function(callback) {
                    $('<div id="myelfinder" />').elfinder({
                        url : '/default/elfinder',
                        lang : 'en',
                        fileURL  : false,
                        dialog : { width : 900, modal : true, title : 'Upload je foto\s' },
                        closeOnEditorCallback : true,
                        editorCallback : callback
                    })
                }
            }
            $('.text').elrte(opts);

RE: Get content of editor - error - Added by Dmitry Levashov about 1 year ago

$("#activity_descr") and $('.text') is the same element?

RE: Get content of editor - error - Added by Dave Jansen about 1 year ago

Yes :-)

(.text is for general purpose for me, in the case i have more editors than one)

RE: Get content of editor - error - Added by Dmitry Levashov about 1 year ago

Please, post here full your script

RE: Get content of editor - error - Added by Dave Jansen about 1 year ago

@ Dmitry:

The above code i pasted is my full javascript

@Troex :

You place the init of Elrte in your .ready()?
And what about the event on the onclick handler?

RE: Get content of editor - error - Added by Troex Nevelin about 1 year ago

Dave Jansen wrote:

You place de init of Elrte in your .ready()? And what about the event on the onclick handler?

The same, I put everything inside .ready()

RE: Get content of editor - error - Added by Dave Jansen about 1 year ago

Okay i did find out where my problem was (don't know exactly what it does).
Further on in my script (outside .ready() ), i had a .get() function call.
When i did remove that call (the page that was called did not have any javascript or so on), elrte did call perfectly my value.
When i place it back it doesn't call the value (and neither gives an error with firebug and dragonfly).

Don't know if this is a common problem?
I use elrte 1.2 and jquery 1.5.1

(1-9/9)