Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Dropdown] Unable to attach handler to onChange or onAdd after a dropdown has been initialized #3744

Closed
douglasg14b opened this issue Feb 24, 2016 · 7 comments
Milestone

Comments

@douglasg14b
Copy link

If a dropdown has been initialized, you cannot add a handler for the onChange or onAdd events, it only works if they are added during initialization.

During init:

$('#testThings2').dropdown({ onAdd: function(addedValue){ console.log(addedValue); } });

After Init:

$('#testThings').dropdown('setting', 'onAdd', function(addedValue){console.log(addedValue)});

JSFiddle: https://jsfiddle.net/q7yg99Ld/

@jlukic jlukic added this to the 2.1.9 milestone Mar 9, 2016
@jlukic jlukic modified the milestones: 2.1.9, 2.2 May 4, 2016
@jlukic jlukic modified the milestones: 2.2, 2.2.1 May 15, 2016
@jlukic jlukic modified the milestones: 2.2.3, 2.2.4 Aug 22, 2016
@fakenickels
Copy link

any updates on this?

@shadoWalker89
Copy link

This feature is a must have

@jlukic
Copy link
Member

jlukic commented Sep 12, 2016

As a sidenote, this is specifically related to calling .setting() on the original <select> element, if you use setting('onAdd') on the generated dropdown everything works correctly.

@fakenickels
Copy link

@jlukic is right! It doesn't work on the select element, you invoke it in the element where the dropdown was initialized.

@shadoWalker89
Copy link

@jlukic But i will have to do something like this each time

$('#SomeSelect').closest('.ui.dropdown').dropdown('setting', 'onAdd', function(){});

What is expected is this

$('#SomeSelect').dropdown('setting', 'onAdd', function(){});

Maybe you could add this and deprecate the .ui.dropdown solution.

@jlukic jlukic modified the milestones: 2.2.5, 2.2.6, 2.2.7 Oct 28, 2016
@jlukic jlukic changed the title Unable to attach handler to onChange or onAdd after a dropdown has been initialized [Dropdown] Unable to attach handler to onChange or onAdd after a dropdown has been initialized Feb 20, 2017
@jlukic jlukic removed this from the 2.2.8 milestone Feb 21, 2017
@jlukic jlukic modified the milestones: 2.2.9, 2.2.8 Feb 21, 2017
@jlukic jlukic modified the milestones: 2.2.10, 2.2.11 Mar 28, 2017
@jlukic jlukic modified the milestones: 2.2.11, 2.2.12 Jul 11, 2017
jlukic added a commit that referenced this issue Aug 6, 2017
@jlukic
Copy link
Member

jlukic commented Aug 6, 2017

module.setup.reference(), which is used to match a select to dropdown when invoking methods, was not correctly pulling the original dropdown instance when modifying the reference. It was using a new instance.

In current versions calling dropdown methods on a <select> worked for methods like set selected etc that dont change the instance data (since dom references are all still there), but setting does change the underlying data so it failed to work

jlukic added a commit that referenced this issue Aug 6, 2017
@jlukic jlukic closed this as completed Aug 6, 2017
@douglasg14b
Copy link
Author

douglasg14b commented Aug 7, 2017

@jlukic Happy to see you back and committing :)

Anything the community can do to help? Based on the direction you want the project to go...etc?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants