使用 .live() 绑定 jQuery UI 自动完成 [英] Bind jQuery UI autocomplete using .live()

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

问题描述

我到处搜索,但似乎找不到任何帮助...

I've searched everywhere, but I can't seem to find any help...

我有一些通过 JS 动态创建的文本框,所以我需要将它们的所有类绑定到自动完成.因此,我需要使用新的 .live() 选项.

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.

举个例子,绑定现在和未来创建的 .foo 类的所有项目:

As an example, to bind all items with a class of .foo now and future created:

$('.foo').live('click', function(){
  alert('clicked');
});

它需要(和行为)与 .bind() 相同.但是,我想绑定一个自动完成...

It takes (and behaves) the same as .bind(). However, I want to bind an autocomplete...

这不起作用:

$('.foo').live('autocomplete', function(event, ui){
  source: 'url.php' // (surpressed other arguments)
});

如何使用 .live() 绑定自动完成?

How can I use .live() to bind autocomplete?

更新

用 Framer 解决了:

Figured it out with Framer:

$(function(){
  $('.search').live('keyup.autocomplete', function(){
    $(this).autocomplete({
      source : 'url.php'
    });
  });
});

推荐答案

如果你正在使用 jquery.ui.autocomplete.js 试试这个

If you are using the jquery.ui.autocomplete.js try this instead

.bind("keydown.autocomplete") or .live("keydown.autocomplete")

如果没有,使用 jquery.ui.autocomplete.js 看看它是否会工作

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 UI 自动完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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