aboutsummaryrefslogtreecommitdiff
path: root/js/bootstrap-typeahead.js
diff options
context:
space:
mode:
authorMark Otto <[email protected]>2012-12-08 17:40:42 -0800
committerMark Otto <[email protected]>2012-12-08 17:40:42 -0800
commitbc0b94a3fdc8fe480c74f4494073e2c0addb265e (patch)
treee13fec2ed829b4586fa4044fffc8dbfadddae54e /js/bootstrap-typeahead.js
parentbe5f31480b53555c492e0077c8bb9f419fc48f62 (diff)
parent9376a7c221a64c2bf508d02ea2ccd85748d10fcc (diff)
downloadbootstrap-bc0b94a3fdc8fe480c74f4494073e2c0addb265e.tar.xz
bootstrap-bc0b94a3fdc8fe480c74f4494073e2c0addb265e.zip
Merge branch 'master' into 3.0.0-wip
Conflicts: docs/assets/css/bootstrap.css docs/assets/js/bootstrap.js docs/css.html docs/templates/pages/base-css.mustache docs/templates/pages/components.mustache docs/templates/pages/javascript.mustache less/breadcrumbs.less less/tables.less less/tests/css-tests.html
Diffstat (limited to 'js/bootstrap-typeahead.js')
-rw-r--r--js/bootstrap-typeahead.js31
1 files changed, 22 insertions, 9 deletions
diff --git a/js/bootstrap-typeahead.js b/js/bootstrap-typeahead.js
index f1ab231b3..94101db05 100644
--- a/js/bootstrap-typeahead.js
+++ b/js/bootstrap-typeahead.js
@@ -33,8 +33,8 @@
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.$menu = $(this.options.menu)
this.shown = false
this.listen()
}
@@ -56,16 +56,18 @@
}
, show: function () {
- var pos = $.extend({}, this.$element.offset(), {
+ var pos = $.extend({}, this.$element.position(), {
height: this.$element[0].offsetHeight
})
- this.$menu.css({
- top: pos.top + pos.height
- , left: pos.left
- })
+ this.$menu
+ .insertAfter(this.$element)
+ .css({
+ top: pos.top + pos.height
+ , left: pos.left
+ })
+ .show()
- this.$menu.show()
this.shown = true
return this
}
@@ -217,7 +219,7 @@
}
, keydown: function (e) {
- this.suppressKeyPressRepeat = !~$.inArray(e.keyCode, [40,38,9,13,27])
+ this.suppressKeyPressRepeat = ~$.inArray(e.keyCode, [40,38,9,13,27])
this.move(e)
}
@@ -276,6 +278,8 @@
/* TYPEAHEAD PLUGIN DEFINITION
* =========================== */
+ var old = $.fn.typeahead
+
$.fn.typeahead = function (option) {
return this.each(function () {
var $this = $(this)
@@ -297,7 +301,16 @@
$.fn.typeahead.Constructor = Typeahead
- /* TYPEAHEAD DATA-API
+ /* TYPEAHEAD NO CONFLICT
+ * =================== */
+
+ $.fn.typeahead.noConflict = function () {
+ $.fn.typeahead = old
+ return this
+ }
+
+
+ /* TYPEAHEAD DATA-API
* ================== */
$(document).on('focus.typeahead.data-api', '[data-provide="typeahead"]', function (e) {