Jeditable和.live():一个问题

时间:2011-11-28 19:09:32

标签: javascript jquery jeditable

我在页面加载后通过JavaScript动态创建了内容,如下所示:

<div id="filetree" class="">
    <ul class="jqueryFileTree" style="">
        <li class="directory collapsed"><a class="editable" id="920081112" href="#" rel="../../../aamirafridi-jQuery-UI-Scrollable-Tabs-2.0-c2b4056/">aamirafridi-jQuery-UI-Scrollable-Tabs-2.0-c2b4056</a></li>
        <li class="directory collapsed"><a class="editable" id="920081113" href="#" rel="../../../CloudCoding/">CloudCoding</a></li><li class="directory collapsed"><a class="editable" id="920081114" href="#" rel="../../../CloudCoding2/">CloudCoding2</a></li>
        <li class="directory collapsed"><a class="editable" id="920081115" href="#" rel="../../../CloudCodingInterface/">CloudCodingInterface</a></li>
        <li class="directory collapsed"><a class="editable" id="920081116" href="#" rel="../../../jquery-ui/">jquery-ui</a></li>
    </ul>
</div>

由于内容是通过JavaScript创建的,因此我需要使用.live()来使jeditable正常工作。

我还有一个右键单击菜单,点击其中一个项目后应激活jeditable此项目:

$.contextMenu({
    selector: 'ul.jqueryFileTree > li > a', 
    callback: function(key, options) {
            var m = "clicked: " + key;
            window.console && console.log(m);
            if(key == 'rename'){
                            c = $(this);
            id = "#" + $(c).attr('id');
                alert('veniamo chi arria prima')
                window.console && console.log(c);
                window.console && console.log(id);

                $('.editable').trigger("edit1");
                }
        },
        items: {
            "rename": {name: "Rename", icon: "edit", accesskey: "r"},
            "cut": {name: "Cut", icon: "cut", accesskey: "c"},
            // first unused character is taken (here: o)
            "copy": {name: "Copy", icon: "copy", accesskey: "c o p y"},
            // words are truncated to their first letter (here: p)
            "paste": {name: "Paste", icon: "paste", accesskey: "cool paste"},
            "delete": {name: "Delete", icon: "delete"},
        }
    });


$('.icon-edit').live('click',function(event) {
$(id).editable("http://www.example.com/save.php", {

    event: 'edit1',

    });
});

我有一个问题:

1-)我第一次单击某个元素时,jedtable不起作用,第二次是,我认为这是.live()所致。

0 个答案:

没有答案