1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-08-22 13:13:03 +02:00

don't wait for ready when binding events to document

This commit is contained in:
Carl Porth
2012-09-27 15:00:02 -07:00
parent 474471b831
commit e1f6458e36
8 changed files with 43 additions and 60 deletions

View File

@@ -83,8 +83,6 @@
/* ALERT DATA-API /* ALERT DATA-API
* ============== */ * ============== */
$(function () {
$(document).on('click.alert.data-api', dismiss, Alert.prototype.close) $(document).on('click.alert.data-api', dismiss, Alert.prototype.close)
})
}(window.jQuery); }(window.jQuery);

View File

@@ -85,12 +85,10 @@
/* BUTTON DATA-API /* BUTTON DATA-API
* =============== */ * =============== */
$(function () {
$(document).on('click.button.data-api', '[data-toggle^=button]', function (e) { $(document).on('click.button.data-api', '[data-toggle^=button]', function (e) {
var $btn = $(e.target) var $btn = $(e.target)
if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn') if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn')
$btn.button('toggle') $btn.button('toggle')
}) })
})
}(window.jQuery); }(window.jQuery);

View File

@@ -163,7 +163,6 @@
/* CAROUSEL DATA-API /* CAROUSEL DATA-API
* ================= */ * ================= */
$(function () {
$(document).on('click.carousel.data-api', '[data-slide]', function (e) { $(document).on('click.carousel.data-api', '[data-slide]', function (e) {
var $this = $(this), href var $this = $(this), href
, $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7 , $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
@@ -171,6 +170,5 @@
$target.carousel(options) $target.carousel(options)
e.preventDefault() e.preventDefault()
}) })
})
}(window.jQuery); }(window.jQuery);

View File

@@ -143,7 +143,6 @@
/* COLLAPSIBLE DATA-API /* COLLAPSIBLE DATA-API
* ==================== */ * ==================== */
$(function () {
$(document).on('click.collapse.data-api', '[data-toggle=collapse]', function (e) { $(document).on('click.collapse.data-api', '[data-toggle=collapse]', function (e) {
var $this = $(this), href var $this = $(this), href
, target = $this.attr('data-target') , target = $this.attr('data-target')
@@ -153,6 +152,5 @@
$this[$(target).hasClass('in') ? 'addClass' : 'removeClass']('collapsed') $this[$(target).hasClass('in') ? 'addClass' : 'removeClass']('collapsed')
$(target).collapse(option) $(target).collapse(option)
}) })
})
}(window.jQuery); }(window.jQuery);

View File

@@ -138,13 +138,10 @@
/* APPLY TO STANDARD DROPDOWN ELEMENTS /* APPLY TO STANDARD DROPDOWN ELEMENTS
* =================================== */ * =================================== */
$(function () {
$('html')
.on('click.dropdown.data-api touchstart.dropdown.data-api', clearMenus)
$(document) $(document)
.on('click.dropdown.data-api touchstart.dropdown.data-api', clearMenus)
.on('click.dropdown touchstart.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() }) .on('click.dropdown touchstart.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() })
.on('click.dropdown.data-api touchstart.dropdown.data-api' , toggle, Dropdown.prototype.toggle) .on('click.dropdown.data-api touchstart.dropdown.data-api' , toggle, Dropdown.prototype.toggle)
.on('keydown.dropdown.data-api touchstart.dropdown.data-api', toggle + ', [role=menu]' , Dropdown.prototype.keydown) .on('keydown.dropdown.data-api touchstart.dropdown.data-api', toggle + ', [role=menu]' , Dropdown.prototype.keydown)
})
}(window.jQuery); }(window.jQuery);

View File

@@ -215,7 +215,6 @@
/* MODAL DATA-API /* MODAL DATA-API
* ============== */ * ============== */
$(function () {
$(document).on('click.modal.data-api', '[data-toggle="modal"]', function (e) { $(document).on('click.modal.data-api', '[data-toggle="modal"]', function (e) {
var $this = $(this) var $this = $(this)
, href = $this.attr('href') , href = $this.attr('href')
@@ -230,6 +229,5 @@
$this.focus() $this.focus()
}) })
}) })
})
}(window.jQuery); }(window.jQuery);

2
js/bootstrap-tab.js vendored
View File

@@ -125,11 +125,9 @@
/* TAB DATA-API /* TAB DATA-API
* ============ */ * ============ */
$(function () {
$(document).on('click.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) { $(document).on('click.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) {
e.preventDefault() e.preventDefault()
$(this).tab('show') $(this).tab('show')
}) })
})
}(window.jQuery); }(window.jQuery);

View File

@@ -297,13 +297,11 @@
/* TYPEAHEAD DATA-API /* TYPEAHEAD DATA-API
* ================== */ * ================== */
$(function () {
$(document).on('focus.typeahead.data-api', '[data-provide="typeahead"]', function (e) { $(document).on('focus.typeahead.data-api', '[data-provide="typeahead"]', function (e) {
var $this = $(this) var $this = $(this)
if ($this.data('typeahead')) return if ($this.data('typeahead')) return
e.preventDefault() e.preventDefault()
$this.typeahead($this.data()) $this.typeahead($this.data())
}) })
})
}(window.jQuery); }(window.jQuery);