Trying to bind the 'change' event to a cleditor

186 views
Skip to first unread message

Tobiah

unread,
Mar 1, 2012, 2:23:26 PM3/1/12
to cleditor
I have a cleditor, let's say the ID is 'myeditor'.

I am trying to go $('#myeditor').bind('change', myhandler), but
myhandler never gets called when I change text in the cleditor and
blur.
I do the same thing with a text input box, and myhandler() gets
called
fine. Is there a way I can bind to an event when I change the text
of a cleditor?

Thanks!

Tobiah

Rollasoc

unread,
Sep 28, 2012, 11:22:52 AM9/28/12
to cled...@googlegroups.com
I have a similar problem  
I think the issue is to do with the editor being inside an iframe, so the event never bubbles up to your code.
 
Someone else posted this, which could possibly solve your issue.  Maybe?
 
$(document).ready(function() {
var editor = $("#input").cleditor();
editor.change(function() {
alert("change event");
});
});

Rolando Escobar

unread,
Nov 24, 2013, 11:48:48 AM11/24/13
to cled...@googlegroups.com
This work for me... 

       $(document).ready(function () {
            $(".textarea").each(function () {
                var cledDesc = $(this).cleditor()[0];
                var frameDesc = cledDesc.$frame[0].contentWindow.document;
                var nombre = $(this).attr('id');
                $(frameDesc).bind("keyup change", { id: nombre }, function (event) {
                    if (event.which == 46 || event.which == 8) {
                        var text = cledDesc.$area.val();
                        ... any action
                    }
                });
            });
        });

KenHanks

unread,
Nov 11, 2018, 1:28:15 PM11/11/18
to cleditor
If you're using a JQuery version greater than 3.0, you should be aware that "bind" was deprecated and eventually removed (I think). You should use "on" instead.
That's according to the JQUERY docs.
Reply all
Reply to author
Forward
0 new messages