]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
Allow updater function (updates the value of the input field) to be overridden.
authorNirav Sanghani <nirav.sanghani@gmail.com>
Tue, 17 Apr 2012 00:05:35 +0000 (17:05 -0700)
committerNirav Sanghani <nirav.sanghani@gmail.com>
Tue, 17 Apr 2012 00:05:35 +0000 (17:05 -0700)
js/bootstrap-typeahead.js

index 526cf320c3589d6e85304a92c9489e7fdc35d4ec..4c562f7536c3beb86ac327f5b2ed89133cb7c9a0 100644 (file)
@@ -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
   , 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