将keyup操作添加到niceEdit版本的iframe [英] Adding keyup action to iframe of version of niceEdit

查看:196
本文介绍了将keyup操作添加到niceEdit版本的iframe的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在iframe格式中使用nicEdit。每次用户在编辑器中写入任何内容(keyup事件)时,我都需要运行另一个js / jquery函数。如何将此自定义键盘操作添加到所需的iframe?

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?

推荐答案

答案实际上在于js代码。在nicEdit.js中搜索:

The answer actually lies in the js code. In the nicEdit.js search for :

var nicEditorIFrameInstance = nicEditorInstance.extend({

在此内部,在 initFrame 函数中,
查找 this.frameDoc.addEvent
这是添加事件的地方(通过addEvent)。这包括你的keyup语句:

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))

您需要添加 closureListener(this)才能使其正常工作。然后在initFrame函数之后创建YOURFUNCTION:

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
},

这个方法对我有用。希望它也适合你.nicEdit是迄今为止我遇到的最糟糕的第三方记录。

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.

这篇关于将keyup操作添加到niceEdit版本的iframe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆