Semantic-ui: [Dropdown] onChange fires every value when setting or clearing values of a multiple selection dropdown

Created on 16 Jan 2017  路  3Comments  路  Source: Semantic-Org/Semantic-UI

When setting values with "set selected/exactly" or clearing values with "clear", onChange gets triggered for each value that gets added/removed.

https://jsfiddle.net/dbr26njq/48/

  1. Open dev tools, and watch the console
  2. Click button "Set Values".
  3. Click button "Clear Values".
  4. Look at the console.log statements

Expected:
I would expect that setting and clearing multiple values only would trigger one onChange.

Enhancement Evaluating Bug / Change stale

Most helpful comment

Can you please re-open this. Not the same thing as disabling onChange all together (https://github.com/Semantic-Org/Semantic-UI/issues/5212)

There should be a option to trigger onChange only once for multiple values with "set selected/exactly", "clear" etc.

Or has anybody managed to find a workaround for this?

All 3 comments

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 30 days if no further activity occurs. Thank you for your contributions.

Can you please re-open this. Not the same thing as disabling onChange all together (https://github.com/Semantic-Org/Semantic-UI/issues/5212)

There should be a option to trigger onChange only once for multiple values with "set selected/exactly", "clear" etc.

Or has anybody managed to find a workaround for this?

One option - but it is a workaround in my eyes - would be to destroy the dropdown before you clear/add items and then reinitialize it, call "set selected" and then add the onChange handler with "settings".

$('.dropdown')
  .destroy()
  .dropdown('set selected', value)
  .dropdown('settings', { 
    onChange: someFunction 
  });
Was this page helpful?
0 / 5 - 0 ratings

Related issues

miguelmota picture miguelmota  路  3Comments

playgithub picture playgithub  路  3Comments

guilhermeblanco picture guilhermeblanco  路  3Comments

deneuxa picture deneuxa  路  3Comments

davialexandre picture davialexandre  路  3Comments