From: Jacob Thornton Date: Fri, 30 Sep 2011 06:00:10 +0000 (-0700) Subject: change event to use target and relatedTarget (which more closely resembles actual... X-Git-Tag: v1.4.0~62^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a0bf8b67ff4dd827f9298563616ecc519e7924c8;p=thirdparty%2Fbootstrap.git change event to use target and relatedTarget (which more closely resembles actual event api) --- diff --git a/docs/javascript.html b/docs/javascript.html index 1f5ad1a38f..956dfd0a83 100644 --- a/docs/javascript.html +++ b/docs/javascript.html @@ -368,14 +368,15 @@ $('#my-modal').bind('hidden', function () { change - This event fires on tab change. The event provides an additional parameter which holds the id of the previous tab and the id of the new current tab. This information is stored in an object with two properties called from and to, e.g. { to: '#home', from: '#profile' }. + This event fires on tab change. Use event.target and event.relatedTarget to target the active tab and the previous active tab respectively.
-$('#.tabs').bind('changed', function (e, c) {
-  // do something with c.from and c.to ...
+$('#.tabs').bind('change', function (e) {
+  e.target // activated tab
+  e.relatedTarget // previous tab
 })

Demo

') - , changeCount = 0 - , from - , to; - - $tabsHTML.tabs().bind( "change", function (e, c){ - from = c.from; - to = c.to; - changeCount++ - }) - - $tabsHTML.tabs().find('a').last().click() - - equals(from, "#home") - equals(to, "#profile") - equals(changeCount, 1) + , $target + , count = 0 + , relatedTarget + , target + + $tabsHTML + .tabs() + .bind( "change", function (e) { + target = e.target + relatedTarget = e.relatedTarget + count++ + }) + + $target = $tabsHTML + .find('a') + .last() + .click() + + equals(relatedTarget, $tabsHTML.find('a').first()[0]) + equals(target, $target[0]) + equals(count, 1) }) }) \ No newline at end of file