1

Same code I'm using of dojo documentation
just downloaded code work fine but onchange event do not fire on my project.
I have make it to work by firing onblur onBlur: function(){alert(3)}
What thing may cause onchange event not fire?

var filteringSelect = new FilteringSelect({
        id: "stateSelect",
        name: "state",
        value: "CA",
        store: stateStore,
        searchAttr: "name",     
        onChange: function(){alert(3)}
    }, "stateSelect");
4

2 回答 2

3

Just put different id on the array like:

var stateStore = new Memory({
        data: [
            {name:"Alabama", id:"AL"},
            {name:"Alaska", id:"AK"}
              ]
});
  1. If there is no id on your Array, onChange event will not fire
  2. If the value of two id are same, onChange event will fire just for the first time.
于 2013-06-26T10:18:49.260 回答
1

I think something else is wrong since it's working fine here. I even made a JSFiddle to show it's working.

Also, there is another way (I think it's more preferred too) by using the dojo/on module:

on(filteringSelect, 'change', function() {
       alert(3); 
});

Another JSFiddle to demonstrate this can be found here.

于 2013-06-26T07:45:22.603 回答