Skip to content
New issue

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

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

Already on GitHub? # to your account

add() method messes with selection #317

Closed
davidkrijgsman opened this issue Nov 26, 2015 · 0 comments
Closed

add() method messes with selection #317

davidkrijgsman opened this issue Nov 26, 2015 · 0 comments
Milestone

Comments

@davidkrijgsman
Copy link

I'm trying to dynamically add an option by doing the following.

HTML:

<select id="test" name="test">
    <option value="1">Option 1</option>
    <option value="2">Option 2</option>
    <option value="3">Option 3</option>
</select>

<button>Add option 4</button>

Javascript:

<script>
jQuery(document).ready(function()
{
    jQuery('#test').dropkick();

    jQuery('button').on('click', function(e)
    {
        jQuery('#test').dropkick('add', 'Option 4');
    });
});
</script>

The option gets added, both in the DOM select as well as in the Dropkick options. However, when I try to select the new option ('Option 4'), 'Option 3' is marked as selected. When I select 'Option 3', 'Option 4' gets selected. If I add multiple options, the option directly above it gets selected.

Everything is fine after I call the refresh() method. Is that the intended use? Or is it supposed to refresh automatically?

@Robdel12 Robdel12 added this to the v2.1.8 milestone Apr 19, 2016
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants