"set selected" worked, but onchange not be triggered. Should not?
This is similar behavior to jQuery - it is programmer's responsibility to call triggers (jQuery('.foo').trigger('change')).
I'm here to please. :smiley_cat:
Adding onChange to set selected in 1.1.0
Am I the only one who needs OnChange not to be triggered when 'set selected' is called?
On load I want to prepopulate the dropdown with selections from the server (using 'set selected') and only call the OnChange when the user manually selects an item (so it can be added to the server db too).
A possibility would be for the OnChange to get an additional parameter to define whether is called from 'set selected' or from user action.
set selected could have a third parameter "silent", to prevent triggering onChange which is set to false by default. This would be a non-breaking change:
$elem.dropdown('set selected', value, silent);
Example for a silent value change:
$elem.dropdown('set selected', [23, 33, 119], true);
Example for a regular value change triggering onChange (as to now):
$elem.dropdown('set selected', [23, 33, 119]);
+1 @activeperception @achimkoellner
@jlukic is this possible?
@xxRockOnxx You might be able to achieve this by changing dropdown module settings: http://semantic-ui.com/modules/dropdown.html#/settings
Looking at the code that introduced the onChange call you can see all it does it calls $.proxy towards settings.onChange.
I'd say it is a mistake to add it in the first place (in my opinion you should follow the path of least side effects) and it did introduce a breaking change, since onChange was never called before, and now it does without asking.
I do have a workaround but having silent parameter would be good.
I instead find the hidden input and set the value to empty. Same thing to the .text
Most helpful comment
Am I the only one who needs OnChange not to be triggered when 'set selected' is called?
On load I want to prepopulate the dropdown with selections from the server (using 'set selected') and only call the OnChange when the user manually selects an item (so it can be added to the server db too).
A possibility would be for the OnChange to get an additional parameter to define whether is called from 'set selected' or from user action.