Skip to content

Commit

Permalink
Merge pull request #28 from serialc/master
Browse files Browse the repository at this point in the history
Added autoselect option
  • Loading branch information
Jamie Appleseed committed Dec 27, 2011
2 parents c1631df + fc74b35 commit 3f02e97
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions README
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added option allowing automatic input text selection on mouse click.
7 changes: 7 additions & 0 deletions jquery.select-to-autocomplete.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ THE SOFTWARE.
'sort': false,
'sort-attr': 'data-priority',
'sort-desc': false,
'autoselect': true,
'alternative-spellings': true,
'alternative-spellings-attr': 'data-alternative-spellings',
'remove-valueless-options': true,
Expand Down Expand Up @@ -63,6 +64,12 @@ THE SOFTWARE.
settings['handle_invalid_input'](context);
}
});
// give the input box the ability to select all text on mouse click
if ( context.settings['autoselect'] ) {
$text_field.click( function() {
this.select();
});
}
return $text_field.val( context.$select_field.find('option:selected:first').text() )
.insertAfter( context.$select_field );
},
Expand Down

0 comments on commit 3f02e97

Please sign in to comment.