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

merged 2 commits into from Oct 18, 2012


None yet

badcarl commented Sep 27, 2012

By binding data-api events to document, we can replace the body element without losing the bindings.

This is necessary to be compatible with and other javascript libraries that replace body.

badcarl referenced this pull request in turbolinks/turbolinks-classic Sep 27, 2012


Removing body also removes event listeners on body #16

josh commented Sep 27, 2012

You don't need to wait till ready anymore either.

This solved my problem and seems to work fine.

Works fine, looking forward to this making it into the next release!

badcarl referenced this pull request in turbolinks/turbolinks-classic Oct 5, 2012


Issues with bootstrap plugins #78

caarlos0 commented Oct 7, 2012

solve my problem too..

ollym commented Oct 7, 2012

+1 can you merge this please

This solved my problem when using Turbolinks too.

pusewicz commented Oct 8, 2012


4ware commented Oct 8, 2012


Bertg commented Oct 9, 2012


jpzwarte commented Oct 9, 2012

Ran into the same problem, this solved it.

+1 We really need it!

fred commented Oct 12, 2012

👍 Please :)

@fat fat commented on the diff Oct 18, 2012

@@ -138,13 +138,10 @@
* =================================== */
- $(function () {
- $('html')
- .on('', clearMenus)
- $('body')
- .on('click.dropdown', '.dropdown form', function (e) { e.stopPropagation() })
- .on('' , toggle, Dropdown.prototype.toggle)
- .on('', toggle + ', [role=menu]' , Dropdown.prototype.keydown)
- })
+ $(document)

fat Oct 18, 2012


this is a breaking change. you need to still bind to html i believe


fat Oct 18, 2012


hm nope, seems to work fine… though it will probably break something weird and we'll be sad in the future.


fat Oct 18, 2012


hopefully not tho


josh Oct 18, 2012

i can't imagine what you could be doing for it to make a difference.

w/ the old school $, jquery defaulted to binding to document. still a fine delegation context.


fat Oct 18, 2012


document > body tho


fat Oct 18, 2012


im not gonna worry about it

fat merged commit e1f6458 into twbs:2.1.2-wip Oct 18, 2012

1 check passed

default The Travis build passed

@jasny jasny referenced this pull request in jasny/bootstrap Jan 15, 2013

@jasny jasny Bind to document instead of 'body'
As per twitter#5308

@charlesbjohnson charlesbjohnson pushed a commit to charlesbjohnson/bootstrap that referenced this pull request Dec 9, 2014

@ghiculescu ghiculescu Bind to document instead of 'body'
As per twbs#5308
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment