使用.live绑定jQuery用户界面自动完成() [英] Bind jQuery UI autocomplete using .live()
问题描述
我搜索无处不在,但我似乎无法找到任何帮助...
我有通过JS动态创建文本框的一些,所以我需要所有的类绑定到一个自动完成。因此,我需要使用新的.live()选项。
作为一个例子,结合一类包含.foo的现在和未来创建的所有项目:
$('富')。生活('点击',功能(){
警报(点击);
});
这需要(和行为)一样.bind()。不过,我想绑定自动完成...
这不工作:
$('富')。生活(自动完成,功能(事件,UI){
来源:url.php'//(河畔pressed其他参数)
});
我
如何使用.live()绑定自动完成?
更新
与成帧器想通了:
$(函数(){
$('搜索')。生活(keyup.autocomplete',函数(){
$(本).autocomplete({
来源:url.php
});
});
});
如果您使用的是 jquery.ui.autocomplete.js
试试这个代替
.bind(keydown.autocomplete)或.live(keydown.autocomplete)
如果没有,使用 jquery.ui.autocomplete.js
,看看它是否会工作
如果不适用,我不知道怎么帮你老兄
I've searched everywhere, but I can't seem to find any help...
I have some textboxes that are created dynamically via JS, so I need to bind all of their classes to an autocomplete. As a result, I need to use the new .live() option.
As an example, to bind all items with a class of .foo now and future created:
$('.foo').live('click', function(){
alert('clicked');
});
It takes (and behaves) the same as .bind(). However, I want to bind an autocomplete...
This doesn't work:
$('.foo').live('autocomplete', function(event, ui){
source: 'url.php' // (surpressed other arguments)
});
How can I use .live() to bind autocomplete?
UPDATE
Figured it out with Framer:
$(function(){
$('.search').live('keyup.autocomplete', function(){
$(this).autocomplete({
source : 'url.php'
});
});
});
If you are using the jquery.ui.autocomplete.js
try this instead
.bind("keydown.autocomplete") or .live("keydown.autocomplete")
if not, use the jquery.ui.autocomplete.js
and see if it'll work
If that doesn't apply, I don't know how to help you bro
这篇关于使用.live绑定jQuery用户界面自动完成()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!