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

Off by one error when searching selected option by a string key #28

Closed
ZeroOne3010 opened this issue Dec 20, 2013 · 0 comments
Closed
Labels

Comments

@ZeroOne3010
Copy link

In jquery.easydropdown.js around line 322 there is this command:

index = self.$select.find('option[value='+index+']').index() - 1;

The .index() function, however, returns a zero-based index, so results returned by that function are off by one.

You should be able to replicate this bug by creating some structure like this:

<select class="dropdown" id="my-foo-select">
<option value="first">First item</option>
<option value="second">Second item</option>
<option value="third">Third item</option>
</select>
<script type="text/javascript">
$(function() {
  $("select#my-foo-select").easyDropDown("select", "third");
});
</script>

Notice how the script should select the third item, but in reality the second item will get selected.

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

No branches or pull requests

2 participants