Commit 8e8b1ad0 authored by Nirav Sanghani's avatar Nirav Sanghani

Allow updater function (updates the value of the input field) to be overridden.

parent 2881269e
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
this.matcher = this.options.matcher || this.matcher this.matcher = this.options.matcher || this.matcher
this.sorter = this.options.sorter || this.sorter this.sorter = this.options.sorter || this.sorter
this.highlighter = this.options.highlighter || this.highlighter this.highlighter = this.options.highlighter || this.highlighter
this.updater = this.options.updater || this.updater
this.$menu = $(this.options.menu).appendTo('body') this.$menu = $(this.options.menu).appendTo('body')
this.source = this.options.source this.source = this.options.source
this.shown = false this.shown = false
...@@ -45,11 +46,15 @@ ...@@ -45,11 +46,15 @@
, select: function () { , select: function () {
var val = this.$menu.find('.active').attr('data-value') var val = this.$menu.find('.active').attr('data-value')
this.$element this.$element
.val(val) .val(this.updater(val))
.change() .change()
return this.hide() return this.hide()
} }
, updater: function (item) {
return item
}
, show: function () { , show: function () {
var pos = $.extend({}, this.$element.offset(), { var pos = $.extend({}, this.$element.offset(), {
height: this.$element[0].offsetHeight height: this.$element[0].offsetHeight
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment