aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNirav Sanghani <[email protected]>2012-04-16 17:05:35 -0700
committerNirav Sanghani <[email protected]>2012-04-16 17:05:35 -0700
commit8e8b1ad03df4f1e723cb58696ebace642fce3946 (patch)
treef4cf544ac73f39f16769a88b64a1e6f3ee621270
parent2881269e16be1beb007633501496d6a8e8924b4b (diff)
downloadbootstrap-8e8b1ad03df4f1e723cb58696ebace642fce3946.tar.xz
bootstrap-8e8b1ad03df4f1e723cb58696ebace642fce3946.zip
Allow updater function (updates the value of the input field) to be overridden.
-rw-r--r--js/bootstrap-typeahead.js7
1 files changed, 6 insertions, 1 deletions
diff --git a/js/bootstrap-typeahead.js b/js/bootstrap-typeahead.js
index 526cf320c..4c562f753 100644
--- a/js/bootstrap-typeahead.js
+++ b/js/bootstrap-typeahead.js
@@ -32,6 +32,7 @@
this.matcher = this.options.matcher || this.matcher
this.sorter = this.options.sorter || this.sorter
this.highlighter = this.options.highlighter || this.highlighter
+ this.updater = this.options.updater || this.updater
this.$menu = $(this.options.menu).appendTo('body')
this.source = this.options.source
this.shown = false
@@ -45,11 +46,15 @@
, select: function () {
var val = this.$menu.find('.active').attr('data-value')
this.$element
- .val(val)
+ .val(this.updater(val))
.change()
return this.hide()
}
+ , updater: function (item) {
+ return item
+ }
+
, show: function () {
var pos = $.extend({}, this.$element.offset(), {
height: this.$element[0].offsetHeight