Permalink
Browse files

Allow setting a placeholder from data attribute

Use data-placeholder="" on the select

fixes #12
  • Loading branch information...
1 parent df3a3d3 commit 96176752ebfa1a4ae152ccab6bc7dff02237fcd4 Daniel Farrell committed Apr 20, 2012
Showing with 9 additions and 1 deletion.
  1. +1 −1 js/bootstrap-combobox.js
  2. +8 −0 js/tests/unit/bootstrap-combobox.js
View
@@ -30,7 +30,7 @@
this.sorter = this.options.sorter || this.sorter
this.highlighter = this.options.highlighter || this.highlighter
this.$menu = $(this.options.menu).appendTo('body')
- this.placeholder = this.options.placeholder || this.placeholder
+ this.placeholder = this.options.placeholder || this.$target.attr('data-placeholder')
this.$element.attr('placeholder', this.placeholder)
this.shown = false
this.refresh()
@@ -220,4 +220,12 @@ $(function () {
equals($input.attr('placeholder'), 'Type something...', 'input value was correctly set')
})
+
+ test("should set placeholder text on the input if specified as an data attribute", function() {
+ var $select = $('<select data-placeholder="Type something..."><option></option><option>aa</option><option selected>ab</option><option>ac</option></select>')
+ , $input = $select.combobox().data('combobox').$element
+ , combobox = $select.data('combobox')
+
+ equals($input.attr('placeholder'), 'Type something...', 'input value was correctly set')
+ })
})

0 comments on commit 9617675

Please sign in to comment.