onChange不足以从Dojo Combobox触发查询 [英] onChange not sufficient to trigger query from Dojo Combobox

查看:212
本文介绍了onChange不足以从Dojo Combobox触发查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这与这篇文章密切相关:
是否有一个onSelect事件或等效的HTML< select>?

this is closely related to this post: Is there an onSelect event or equivalent for HTML <select>?

...但专门针对Dojo ComboBox ..(我是使用具有ArcGIS JSAPI的Dojo)。
我有三个组合框,它使用从下拉列表中的选择触发的查询填充后继。我的问题是如果第二个组合框选择保持不变,则查询不会被触发。我已经尝试使用onblur和其他几个事件而不是onchange,并尝试重置JS中的选择的值,但两者都没有工作。该值被重置,但是组合框仍然像在同一个值一样动作,因此onchange不起作用。我尝试了很多方法在上面的链接,但没有一个为我工作。据我所知,我的组合框不会生成任何selectedIndex。
任何建议?谢谢,J

...but specifically for the Dojo ComboBox..(I am using Dojo w/ ArcGIS JSAPI). I have three combo boxes, which populate the successors using queries triggered by the selections from the dropdown list. My problem is that if the second combobox selection remains the same, the query is not triggered. I have tried using onblur and several other events instead of onchange, and tried to reset the value of the selection in JS, but neither has worked. The value is reset but the combobox still acts as if the same value is there, so onchange does not work. I tried many of the methods in the link above, but none worked for me. As far as I can tell, my comboboxes do not generate any selectedIndex. Any suggestions? Thanks, J

推荐答案

所有三个dijits dijit / form / Select dijit / form / FilteringSelect dijit / form / ComboBox 子类 dijit / _HasDropDown 并添加一个属性 dropDown

All three dijits dijit/form/Select, dijit/form/FilteringSelect and dijit/form/ComboBox subclass dijit/_HasDropDown and that adds them a property dropDown:

// dropDown: [protected] Widget
//     The widget to display as a popup.  This widget *must* be
//     defined before the startup function is called.
dropDown: null

你想要听的是这个 dropDown 小部件。问题是在 ComboBox FilteringSelect 的情况下,此小部件 dijit / form / _ComboBoxMenu 懒得实例化,即当您第一次打开弹出窗口时。所以你需要首先挂钩打开dropDown,然后将 onClick 事件监听器添加到dropDown:

What you want is to listen on this dropDown widget. The problem is that in the case of ComboBox and FilteringSelect this widget dijit/form/_ComboBoxMenu gets instantiated lazily, i.e. when you open popup for the first time. So you need to hook to opening dropDown in the first place and then add onClick event listener to the dropDown:

var signal = aspect.after(comboBox, "openDropDown", function() {
    comboBox.dropDown.on("click", function(node) {
        console.log("value:", comboBox.get("value"));
        console.log("selectedIndex:", domAttr.get(node, "item"));  // <= this is not an identifier
    }
    signal.remove();  // remove aspect so it called only once
}

当使用 dijit / form / Select 时,这很简单,因为 dropDown 存在,您可以立即在其dropDown dijit / Menu 上收听 onExecute

It's a bit easier when working with dijit/form/Select, because dropDown exists and you can listen to onExecute on its dropDown dijit/Menu immediately:

select.dropDown.on("execute", function() {
    setTimeout(function() {
        console.log("value:", select.get("value"))
    });
});

查看actio中的所有三个n在jsFiddle: http://jsfiddle.net/phusick/Hp5jr/

See all three in action at jsFiddle: http://jsfiddle.net/phusick/Hp5jr/

这篇关于onChange不足以从Dojo Combobox触发查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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