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

Manual trigger of change() #257

Closed
macstens opened this issue Dec 1, 2014 · 6 comments
Closed

Manual trigger of change() #257

macstens opened this issue Dec 1, 2014 · 6 comments
Assignees
Milestone

Comments

@macstens
Copy link

macstens commented Dec 1, 2014

Hi! Following problem:

My DropKick select-list has a change function which is working, but at some point I need to trigger it based on another action. It doesn't seem to be possible (at least at a trivial level) - is there a simple trick I didn't see before I start hacking in the original source code?

Thanks!

@wwilsman
Copy link
Collaborator

wwilsman commented Dec 1, 2014

If you could provide some sample code, or a JSBin we could help you out a lot easier.

@macstens
Copy link
Author

macstens commented Dec 2, 2014

Sure, you are right. Here we go: http://jsbin.com/pohosorusi/1/edit?html,js,output

The basic JS code for this reproduced scenario is at the bottom.

@Robdel12 Robdel12 modified the milestone: 2.1 Dec 8, 2014
@volodymyrrudyi
Copy link

hi macstens. Have you managed to find some workaround for this issue until issue is fixed? I was going to create an issue and found this ticket :)

@macstens
Copy link
Author

Unfortunately not... sorry.

@wwilsman
Copy link
Collaborator

Haven't had much time to work on this lately, but we are definitely committed to the 2.1 milestone deadline of January 1st. So expect to see a more elegant solution then.

In the meantime, you could do this:

var dk = new Dropkick( selectElement, {...});

dk.data.settings.change.call( dk );

// or this will just reselect the currently selected option and
// call the change event along with triggering the select's change event.
dk.select( dk.selectedIndex );

The second one is untested, but I don't see why it shouldn't work

@wwilsman
Copy link
Collaborator

If you use the code from the master branch (which you no longer need to include the plugins separately), it should work now.

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

No branches or pull requests

4 participants