我需要在我的组合框完成其过滤器后触发事件
我已经扩展了小部件并试图在通话结束时放弃.done。
search: function(word) {
word = typeof word === "string" ? word : this.text();
var that = this,
length = word.length,
options = that.options,
ignoreCase = options.ignoreCase,
filter = options.filter,
field = options.dataTextField;
clearTimeout(that._typing);
if (length >= options.minLength) {
that._state = STATE_FILTER;
if (filter === "none") {
that._filter(word);
} else {
that._open = true;
that._filterSource({
value: ignoreCase ? word.toLowerCase() : word,
field: field,
operator: filter,
ignoreCase: ignoreCase
}); // .done here does not work :(
}
}
},
我需要知道何时返回一个值,这样一旦我知道输入与值服务器端匹配,我就可以在我的页面上做一些其他的事情。
有人能想出实现这个目标的方法吗? :)
有没有办法在数据源发生变化后触发事件?
答案 0 :(得分:0)
我通过在小部件上使用_busy状态解决了这个问题。 以下代码位于窗口小部件的select函数中,因此每当有人失去焦点时都会触发此事。
如果窗口小部件不忙,它将完成ajax调用。 希望这对某人有用:)
if (data && data.length != 0)
{
for (var i = 0; i < data.length; i++)
{
li = $(that.ul).find('li:nth-child(' + (i + 1) + ')');
if (li.length != 0 && data[i].ProductCode == that.input.val())
{
that._select(li);
return;
}
}
}
if (that._busy && that._busy != null)
{
that.busyCheck = setInterval(function () {
if (!that._busy || that._busy == null) {
clearInterval(that.busyCheck);
if (data && data.length != 0){
for (var i = 0; i < data.length; i++){
li = $(that.ul).find('li:nth-child(' + (i + 1) + ')');
if (li.length != 0 && data[i].ProductCode == that.input.val()){
that._select(li);
return;
}
}
}
}
}, 50);
}
that._AddcodeIsServerValid(false);