问题
I am using nicEdit in its iframe format.Everytime the user write anything in the editor(keyup event), I need to run another js/jquery function. How to add this custom keyup action to the desired iframe?
回答1:
The answer actually lies in the js code. In the nicEdit.js search for :
var nicEditorIFrameInstance = nicEditorInstance.extend({
Inside this, in the initFrame
function,
look for this.frameDoc.addEvent
.
This is where the events are being added(via addEvent). To this include your keyup statement :
addEvent('keyup',this.YOURFUNCTIONAME.closureListener(this))
You need to add closureListener(this)
to get this working.Then create YOURFUNCTION after initFrame function like this :
YOURFUNCTIONAME: function() {
//Do what you like. Probably call any JS function that lies in the file where
//you have included the nicEdit.js
},
This method worked for me. Hope it does for you too. nicEdit is by far the worst documented third party stuff I have ever come across.
来源:https://stackoverflow.com/questions/13163545/adding-keyup-action-to-iframe-of-version-of-niceedit