我正在使用 jqueryui 自动完成功能。我想将自动完成绑定到各种选择器,但是需要为不同的选择器定制自动完成功能的成功、来源等。
//Define execute function for birds
//Define execute function for turtles
$( "#birds,#turtles" ).autocomplete({
source: "search.php",
minLength: 2,
select: function( event, ui ) {
this.execute();
/*based on selector id execute() will call the
right function attached with the selector
if called by birds
call execute function of birds
if called by turtles
call execute function of turtles*/
}
});
那么如何将自定义函数附加到各种对象并让 jquery 基于选择器选择适当的源和自定义函数?