使用live()函数进行jQuery编辑的问题..需要忍者 [英] Problem with jQuery edit-in-place with live() function.. need a ninja

查看:108
本文介绍了使用live()函数进行jQuery编辑的问题..需要忍者的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这可能是一个简单的解决方法,但是我无法将其包裹住...

This is probably an easy fix, but I am having trouble wrapping my brain around it...

我正在使用jQuery即时编辑插件来处理一些div,这些div会即时生成.它应该很简单:单击新创建的div,然后可以编辑内容.我遇到了live()的问题.

I'm using a jQuery edit-in-place plugin for some divs that will be generated on the fly. It should be simple: Click in the newly created div, and be able to edit the contents. I'm running into problems with live().

如果不使用live(),显然对于静态div来说可以正常工作.单击一次,获取可编辑的内容.

Without using live(), it obviously works fine for a static div. Click once, get editable contents.

但是,在使用live()时,我需要双击以编辑内容.然后,在其后单击它的任何时间,只需要一次.这有点像焦点问题.也许修改插件本身会有所帮助?

While using live(), however, I need to double click in order to edit the contents. Then any subsequent time it's clicked, it only takes once. It's sorta like a focus issue. Perhaps modifying the plugin itself would help?

这正是我在说的... http://jsfiddle.net/efflux/62CzU/

Here is exactly what I'm talking about... http://jsfiddle.net/efflux/62CzU/

这与我用live调用editinplace()函数的方式有关:

It has something to do with the way I'm calling the editinplace() function with live:

$('.editable').live('click',function() {
    //event.preventDefault();
    $('.editable').editInPlace({
        callback: function(unused, enteredText) { return enteredText; },
        bg_over: "#cff",
        field_type: "textarea",
        textarea_rows: "5",
        textarea_cols: "3",
        saving_image: "./images/ajax-loader.gif"
    });  
 });   

如何使就地编辑插件在通过js创建的div上正常运行?

How can get the edit-in-place plugin to function normally on my divs created via js?

任何帮助将不胜感激!

推荐答案

它不起作用,因为只有在单击它之前才对其进行设置.一旦单击它,就可以设置EditInPlace,这需要它自己单击.设置完毕后,只需触发另一次点击即可: http://jsfiddle.net/62CzU/6/

It doesn't work because it's not set up until you click on it. Once you click on it, you set up the EditInPlace which requires it's own click. Just trigger another click after you set it up: http://jsfiddle.net/62CzU/6/

这篇关于使用live()函数进行jQuery编辑的问题..需要忍者的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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