Skip to content

Commit 68b771a

Browse files
Ben-Russellhnrch02
authored andcommitted
Independently delegate data-api selectors
Fixes twbs#14462. Closes twbs#14463 by merging it.
1 parent 94b544c commit 68b771a

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

js/carousel.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@
207207
// CAROUSEL DATA-API
208208
// =================
209209

210-
$(document).on('click.bs.carousel.data-api', '[data-slide], [data-slide-to]', function (e) {
210+
var clickHandler = function (e) {
211211
var href
212212
var $this = $(this)
213213
var $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) // strip for ie7
@@ -223,7 +223,11 @@
223223
}
224224

225225
e.preventDefault()
226-
})
226+
}
227+
228+
$(document)
229+
.on('click.bs.carousel.data-api', '[data-slide]', clickHandler)
230+
.on('click.bs.carousel.data-api', '[data-slide-to]', clickHandler)
227231

228232
$(window).on('load', function () {
229233
$('[data-ride="carousel"]').each(function () {

js/dropdown.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,8 @@
154154
.on('click.bs.dropdown.data-api', clearMenus)
155155
.on('click.bs.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() })
156156
.on('click.bs.dropdown.data-api', toggle, Dropdown.prototype.toggle)
157-
.on('keydown.bs.dropdown.data-api', toggle + ', [role="menu"], [role="listbox"]', Dropdown.prototype.keydown)
157+
.on('keydown.bs.dropdown.data-api', toggle, Dropdown.prototype.keydown)
158+
.on('keydown.bs.dropdown.data-api', '[role="menu"]', Dropdown.prototype.keydown)
159+
.on('keydown.bs.dropdown.data-api', '[role="listbox"]', Dropdown.prototype.keydown)
158160

159161
}(jQuery);

js/tab.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,13 @@
141141
// TAB DATA-API
142142
// ============
143143

144-
$(document).on('click.bs.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) {
144+
var clickHandler = function (e) {
145145
e.preventDefault()
146146
Plugin.call($(this), 'show')
147-
})
147+
}
148+
149+
$(document)
150+
.on('click.bs.tab.data-api', '[data-toggle="tab"]', clickHandler)
151+
.on('click.bs.tab.data-api', '[data-toggle="pill"]', clickHandler)
148152

149153
}(jQuery);

0 commit comments

Comments
 (0)