Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>All three dijits <code>dijit/form/Select</code>, <code>dijit/form/FilteringSelect</code> and <code>dijit/form/ComboBox</code> subclass <code>dijit/_HasDropDown</code> and that adds them a property <code>dropDown</code>:</p> <pre><code>// dropDown: [protected] Widget // The widget to display as a popup. This widget *must* be // defined before the startup function is called. dropDown: null </code></pre> <p>What you want is to listen on this <code>dropDown</code> widget. The problem is that in the case of <code>ComboBox</code> and <code>FilteringSelect</code> this widget <code>dijit/form/_ComboBoxMenu</code> 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 <code>onClick</code> event listener to the dropDown:</p> <pre><code>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")); // &lt;= this is not an identifier } signal.remove(); // remove aspect so it called only once } </code></pre> <p>It's a bit easier when working with <code>dijit/form/Select</code>, because <code>dropDown</code> exists and you can listen to <code>onExecute</code> on its dropDown <code>dijit/Menu</code> immediately:</p> <pre><code>select.dropDown.on("execute", function() { setTimeout(function() { console.log("value:", select.get("value")) }); }); </code></pre> <p>See all three in action at jsFiddle: <a href="http://jsfiddle.net/phusick/Hp5jr/" rel="nofollow">http://jsfiddle.net/phusick/Hp5jr/</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload