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

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

问题描述

这与这篇文章密切相关:
是否有HTML< select> ;?

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

...的onSelect事件或等效项,但是专门用于Dojo ComboBox ...使用Dojo w / ArcGIS JSAPI)。
我有三个组合框,使用从下拉列表中的选择触发的查询填充后续。我的问题是,如果第二个组合框选择保持不变,查询不会被触发。我试过使用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"))
    });
});


b $ b

查看jsFiddle上的三个动作: http://jsfiddle.net/phusick/Hp5jr/

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

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