You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Suppose you have two selects, one for country and other for state, example: select-1: USA and select-2: states of the USA.
When select-1 change it's value, we must update the select-2 with a new list of items (states) and clear the old selected value.
But the in the bind event, I don't have any context about what I should do:
"#select-states": {bind: function(d,v,$c){// This was called when the control changed it's own value?// Or this was called when "select-country" changed it's value?// Or this was called when the "redraw" method was fired (form initialize)?// if the "select-country" control invoked this event, we should update the states.// if the state value just changed, we shouldn't update the select2 list.if(countrychanged)// how to do this?$c.select2({data: states});// if the "select-country" value invoked this event, we should set this to null, if(countrychanged){d.State=null;// The user must select a new value.}elsed.State=v;},"watch": "#select-country"}
Basically, I need I way to tell which event invoked the bind method, so I can respond accordingly.
Looking for when the value parameter is null doesn't work, it doesn't make clear which event invoked the bind function (sometimes null could be a legit value).
Thanks.
Btw, @ermouth, I tested your suggestion of implementation of select2 component (from PR comment), it's working good.
The text was updated successfully, but these errors were encountered:
In general when one control’s init params a) depend on another control’s state, b) init params are frozen after init finishes, you put depending control as an element of a list and make this list rebuild on first control change.
As for select2 there’s a shorter way (never tested it with v4, but it definitely works with 3.5). Something like:
@ermouth Thanks for the suggestion, I'll give it a try.
One think that I noticed in select2 v4 is that you can't call $control.select({ data: newData }) multiple times to update the select, you have to either destroy it before recreating it or use a custom adapter that allows the data to be updated.
Destroying it is not a good option because when you do that, the binding between the control and jquerymy is lost.
Hi,
Suppose you have two selects, one for country and other for state, example: select-1: USA and select-2: states of the USA.
When select-1 change it's value, we must update the select-2 with a new list of items (states) and clear the old selected value.
But the in the
bind
event, I don't have any context about what I should do:Basically, I need I way to tell which event invoked the
bind
method, so I can respond accordingly.Looking for when the
value
parameter is null doesn't work, it doesn't make clear which event invoked the bindfunction
(sometimes null could be a legit value).Thanks.
Btw, @ermouth, I tested your suggestion of implementation of select2 component (from PR comment), it's working good.
The text was updated successfully, but these errors were encountered: