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

Method select(string, disabled) doesn't select/return element matching string v. 2.0.2 #252

Closed
brianAround opened this issue Nov 18, 2014 · 1 comment
Assignees
Milestone

Comments

@brianAround
Copy link
Contributor

When attempting to use the select() method using the string value of one of the options as a first argument, no values are returned and no item is selected.

I am attempting to set the value of a dropkick select using a "related" value determined by an autosuggest on the same page. I've managed to verify that the arguments being passed are correct. The value being passed is an integer, but I'm using String() to ensure that it passes as a string value to the method, and verified that this is happening.

Edit: I believe I've confirmed this problem by adding the following to the unit test code:

QUnit.test( "Dropkick selects an item by option value.", 1, function( assert) {
var dk = new Dropkick("#normal_select");
dk.select("AL");

assert.equal(dk.value, "AL");
});

@brianAround brianAround changed the title Method select(string, disabled) doesn't select/return element matching string Method select(string, disabled) doesn't select/return element matching string v. 2.0.2 Nov 19, 2014
@zenchua
Copy link

zenchua commented Nov 25, 2014

I fixed this by removing the else { return false; } in the following lines and adding the break to break out of the loop:

if ( typeof elem === "string" ) {
  for ( i = 0; i < this.length; i++ ) {
    if ( this.options[ i ].getAttribute( "data-value" ) == elem ) {
      elem = this.options[ i ];
      break;
    }
  }
}

@Robdel12 Robdel12 modified the milestone: 2.1 Dec 8, 2014
@wwilsman wwilsman self-assigned this Dec 18, 2014
wwilsman added a commit that referenced this issue Dec 19, 2014
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