你如何附加一个自定义的回调函数jQuery的自动完成扩展? [英] How do you attach a custom callback function to the jquery autocomplete extension?

查看:96
本文介绍了你如何附加一个自定义的回调函数jQuery的自动完成扩展?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用jQuery 1.0.2自动完成扩展迪伦Verheul,丹G.瑞士人,Anjesh Tuladhar,乔恩Zaefferer。我试图执行时.show()和.hide()从自动完成控制范围之内叫我自己的回调函数。我还没有发现任何方式为它实际上承认我的回调函数。如果任何人都熟悉这个控件,可以帮助我将不胜AP preciative。

I'm using the jquery autocomplete 1.0.2 extension by Dylan Verheul, Dan G. Switzer, Anjesh Tuladhar, Jörn Zaefferer. I am attempting to execute my own callback function when .show() and .hide() are called from within the autocomplete control. I haven't found any way for it to actually recognize my callback function. If anyone is familiar with this control and can help I would be greatly appreciative.

推荐答案

对不起,我没有任何简单的回答你的问题,我查了插件的源$ C ​​$ c和没有发现任何机制来让你想得到你想要的。我认为你必须要更新这个插件自己做,你想它的工作。

Sorry, I don't have any easy answer to your question, I checked the plugin source code and didn't find any mechanism to let you do want you want. I think you'll have to update this plugin yourself to make it work as you wish.

我们的想法是你的回调添加到选项参数,然后把这个插件使用这些回调。首先,你必须修改插件code。转到该负责显示/隐藏自动完成控制,创建该类的功能:

The idea is to add your callbacks to the options parameter and then make the plugin use these callbacks. First, you'll have to modify the plugin code. Go to the function that creates the class in charge of showing/hiding the autocomplete control :

$.Autocompleter.Select = function (options, input, select, config) {

如果您向下滚动,你可以看到,这个函数返回一个对象,显示()隐藏()方法。您可以添加以下code:

If you scroll down, you can see that this function returns an object with show() and hide() methods. You can add the following code :

hide: function() {
    ...
    options.showCallback && options.showCallback(); // Invoke callback function if set
},
...
show: function() {
    ...
    options.hideCallback && options.hideCallback(); // Invoke callback function if set
},

最后,当你创建你自动完成,你应该添加您的回调您的选择:

Finally, when you create your autocomplete, you should add your callbacks to your options:

$("#myTextBox").autocomplete("http://...",
{
    showCallback : function() { /* do what you want here */ },
    hideCallback : function() { /* do what you want here */ }
});

没有测试所有,它只是一个快速和肮脏的解决方案。我希望这有助于。

Not tested at all, it's just a quick and dirty solution. I hope this helps.

这篇关于你如何附加一个自定义的回调函数jQuery的自动完成扩展?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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