editableText插件启用问题
I've been experimenting with this plugin http://valums.com/edit-in-place/, so far so good... But i ran into this problem. I want to update my page when update or new request to save data is sent but if i update this function(edit-in-place) it will add second set of buttons, third, fourth and so on. How could i tell it that it would update just on that returned data, but not all elements? I have an idea it has to do something with each function of jquerys, but I'm not sure as I'm quite new to jquery. Thanks for any help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以为选择器提供一个上下文,例如,如果您现在正在执行此操作
: ajax 回调,在
success
或complete
方法中调用它时为其提供上下文,无论您在何处添加元素,如下所示:, data
给它上下文 (您可以在此处看到$(selector, context)
的选项),这意味着它仅在 返回 data/html,而不是页面上的所有元素。这应该消除在已经运行的元素上选择和运行插件的重复问题。You can give the selector a context, so for example if you're doing this now:
In your ajax callback, give it a context when calling it in the
success
orcomplete
method, wherever you're adding elements, like this:The
, data
gives it a context (you can see options for$(selector, context)
here), this means it's only searching for elements of that class within the returned data/html, not all elements on the page. This should eliminate your repetition issue of it selecting and running the plugin on elements it's already run on.