1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-02-23 18:40:03 +00:00

bind data-api events to document instead of body to allow body replacement

This commit is contained in:
Carl Porth 2012-09-26 23:11:03 -07:00
parent 24e277b85a
commit 474471b831
8 changed files with 8 additions and 8 deletions

View File

@ -84,7 +84,7 @@
* ============== */ * ============== */
$(function () { $(function () {
$('body').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

@ -86,7 +86,7 @@
* =============== */ * =============== */
$(function () { $(function () {
$('body').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')

View File

@ -164,7 +164,7 @@
* ================= */ * ================= */
$(function () { $(function () {
$('body').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
, options = !$target.data('modal') && $.extend({}, $target.data(), $this.data()) , options = !$target.data('modal') && $.extend({}, $target.data(), $this.data())

View File

@ -144,7 +144,7 @@
* ==================== */ * ==================== */
$(function () { $(function () {
$('body').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')
|| e.preventDefault() || e.preventDefault()

View File

@ -141,7 +141,7 @@
$(function () { $(function () {
$('html') $('html')
.on('click.dropdown.data-api touchstart.dropdown.data-api', clearMenus) .on('click.dropdown.data-api touchstart.dropdown.data-api', clearMenus)
$('body') $(document)
.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)

View File

@ -216,7 +216,7 @@
* ============== */ * ============== */
$(function () { $(function () {
$('body').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')
, $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) //strip for ie7 , $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) //strip for ie7

2
js/bootstrap-tab.js vendored
View File

@ -126,7 +126,7 @@
* ============ */ * ============ */
$(function () { $(function () {
$('body').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')
}) })

View File

@ -298,7 +298,7 @@
* ================== */ * ================== */
$(function () { $(function () {
$('body').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()