jQuery UI的使用Jeditable [英] Jquery ui with Jeditable

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

问题描述

我想这code:

<script type="text/javascript">
$(document).ready(function() {
    $('.edit').editable('http://www.example.com/save.php', {
        indicator : 'Saving...',
        tooltip   : 'Click to edit...',
        submit    : 'OK',
        cancel : 'Cancel',
    });

    $('#cv_cd > input').autocomplete({
        source: 'location.php',
        minLength: 2

    });
});
</script>


<div class="edit" id="cv_cd">Type</div>

这code正常工作与&LT;输入/方式&gt; ,但jeditable,不要求是,当我输入的时候被罚下

This code works properly with <inputs />, but with jeditable, no request is sent off when i type something.

搜索code。与萤火虫后,jeditable还创建了一个输入字段,但显然这样的事情没有作品 $( #cv_cd&GT;输入。)自动完成({

After search the code with firebug, jeditable also creates an input field, however apparently something like this didn't works $('#cv_cd > input').autocomplete({

你知道吗?谢谢

推荐答案

.autocomplete()不是的生活的,所以它只绑定到存在于该呼叫的时间元素

.autocomplete() is not live, so it only binds to elements that exist at the time of the call.

在你的情况,你需要使用生活或preferably,委托,以适应事实上在输入元素将不存在,直到用户点击它。明知与自动完成的元素都 UI的自动完成输入类,你可以做一些类似下面,在原有的替换 .autocomplete()

In your case, you'll want to use live or, preferably, delegate to accommodate the fact the input element will not exist until the user clicks on it. Knowing that the elements with autocomplete have ui-autocomplete-input class, you can do something like the following, in replace of the original .autocomplete():

$("#cv_cd").delegate(".ui-autocomplete-input", "focus", function (event) {
    $(this).autocomplete({
        source: 'location.php',
        minLength: 2
    });
});

这篇关于jQuery UI的使用Jeditable的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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