解除jQuery插件的绑定 [英] Unbind jquery plugins

查看:168
本文介绍了解除jQuery插件的绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我确定这很简单,但我正在敲我的头!

I'm sure this is simple but I'm banging my head!

我使用的是优秀的jQuery插件可编辑( http://www.appelsiini.net/projects/jeditable )。用户可以即时创建表单,并单击以编辑标题,正文,正文。

I'm using the excellent jQuery plugin editable (http://www.appelsiini.net/projects/jeditable). Users can create a form on the fly, and click to edit the title, the body of the text, whatnot.

每当用户创建一个新问题时,我重新绑定插件如下所示:

Every time the user creates a new question, I rebind the plugin like so:

$('.edit').editable()

每个包含'编辑'的元素都应该是可编辑的。

Where every element with class 'edit', should be editable.

问题是,以前的编辑元素似乎得到双重限制,即当您点击编辑它们时,输入字段显示,其中包含以下内容:

The problem is, previous 'edit' elements seem to get double bound... that is, when you click to edit them, an input field shows up, containing the following:

<input class="">

这是有道理的,因为它被绑定了两次(或更多)。如何最好地解决这个问题?我的直觉是在所有编辑元素上解除插件的绑定,然后重新绑定,但是我不知道该怎么做。

Which makes sense since it's getting bound twice (or more). How best to approach this issue? My instinct is to unbind the plugin on all 'edit' elements and then rebind it but I don't know how to do this.

感谢您的帮助

推荐答案

插件只是添加到 jQuery.fn 中的一个函数。除非创建者定义了一个删除或破坏方法,否则该函数不能被撤销。

A "plugin" is just a function added to jQuery.fn. Unless the creator defines a remove or destroy method, the function cannot be reversed.

编辑:可编辑函数,当给出参数'destroy' ,解除插件的绑定。

the editable function, when given the parameter 'destroy', unbinds the plugin.

这篇关于解除jQuery插件的绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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