Get content from jquery CLEditor
How can I get conte开发者_如何学JAVAnt data what I am write in CLEditor using jquery keyup?
Wouldn't it make more sense to use CLEditor's .change
event? From the documentation:
change - This event is triggered whenever the contents of the editor have changed. Since change detection is done using the keyup and mouseup events, this event occurs frequently as the user types.
I'm using version 1.3.0 of the cleditor, the following code is unofficial, I might be bad code, because I'm oop noob AND for many other reasons, but until the next release it does the trick for me : here is what I did :
In file jquery.cleditor.js :
add a trickyMethod option : line 100 :
replace this
imagesPath: function() { return imagesPath(); },
by this :
imagesPath: function() { return imagesPath(); },
trickyMethod: function(){}
Make the trickyMethod be called on keyup event : line :878
replace this :
$doc.click(hidePopups)
.bind("keyup mouseup", function() {
refreshButtons(editor);
});
by this :
$doc.click(hidePopups)
.bind("keyup mouseup", function() {
refreshButtons(editor);
editor.options.trickyMethod(editor);
});
Now you can go in your application code and invoke the cleditor with the trickyMethod option :
$("#input").cleditor({
width: 600,
height: 600,
trickyMethod: function(){ alert("sdf"); }
});
精彩评论