Commit 4b40ee69 authored by fat's avatar fat

cleaner way of preventing double click events + clean up tests for jshint

parent 37e899d7
......@@ -242,9 +242,9 @@
$(document).on('click.bs.button.data-api', '[data-toggle^=button]', function (e) {
var $btn = $(e.target)
if ($btn.has('input').length) return // throw away double event for inputs
if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn')
$btn.button('toggle')
e.preventDefault()
})
}(window.jQuery);
......
This diff is collapsed.
......@@ -99,9 +99,9 @@
$(document).on('click.bs.button.data-api', '[data-toggle^=button]', function (e) {
var $btn = $(e.target)
if ($btn.has('input').length) return // throw away double event for inputs
if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn')
$btn.button('toggle')
e.preventDefault()
})
}(window.jQuery);
......@@ -81,19 +81,19 @@ $(function () {
})
test("should check for closest matching toggle", function () {
var group = '<div class="btn-group" data-toggle="buttons"> \
<label class="btn btn-primary active"> \
<input type="radio" name="options" id="option1" checked="true"> Option 1 \
</label> \
<label class="btn btn-primary"> \
<input type="radio" name="options" id="option2"> Option 2 \
</label> \
<label class="btn btn-primary"> \
<input type="radio" name="options" id="option3"> Option 3 \
</label> \
</div>'
var group = '<div class="btn-group" data-toggle="buttons">' +
'<label class="btn btn-primary active">' +
'<input type="radio" name="options" id="option1" checked="true"> Option 1' +
'</label>' +
'<label class="btn btn-primary">' +
'<input type="radio" name="options" id="option2"> Option 2' +
'</label>' +
'<label class="btn btn-primary">' +
'<input type="radio" name="options" id="option3"> Option 3' +
'</label>' +
'</div>'
var group = $(group)
group = $(group)
var btn1 = $(group.children()[0])
var btn2 = $(group.children()[1])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment