mirror of
https://github.com/twbs/bootstrap.git
synced 2025-08-14 01:24:19 +02:00
button without jquery
This commit is contained in:
@@ -106,17 +106,19 @@ $(function () {
|
||||
|
||||
QUnit.test('should check for closest matching toggle', function (assert) {
|
||||
assert.expect(12)
|
||||
var groupHTML = '<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 groupHTML =
|
||||
'<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 = $(groupHTML).appendTo('#qunit-fixture')
|
||||
|
||||
var $btn1 = $group.children().eq(0)
|
||||
@@ -126,13 +128,16 @@ $(function () {
|
||||
assert.ok($btn1.find('input').prop('checked'), 'btn1 is checked')
|
||||
assert.ok(!$btn2.hasClass('active'), 'btn2 does not have active class')
|
||||
assert.ok(!$btn2.find('input').prop('checked'), 'btn2 is not checked')
|
||||
$btn2.find('input').trigger('click')
|
||||
|
||||
EventHandler.trigger($btn2.find('input')[0], 'click')
|
||||
|
||||
assert.ok(!$btn1.hasClass('active'), 'btn1 does not have active class')
|
||||
assert.ok(!$btn1.find('input').prop('checked'), 'btn1 is not checked')
|
||||
assert.ok($btn2.hasClass('active'), 'btn2 has active class')
|
||||
assert.ok($btn2.find('input').prop('checked'), 'btn2 is checked')
|
||||
|
||||
$btn2.find('input').trigger('click') // Clicking an already checked radio should not un-check it
|
||||
EventHandler.trigger($btn2.find('input')[0], 'click') // clicking an already checked radio should not un-check it
|
||||
|
||||
assert.ok(!$btn1.hasClass('active'), 'btn1 does not have active class')
|
||||
assert.ok(!$btn1.find('input').prop('checked'), 'btn1 is not checked')
|
||||
assert.ok($btn2.hasClass('active'), 'btn2 has active class')
|
||||
|
@@ -46,6 +46,8 @@
|
||||
|
||||
<script src="../../../node_modules/jquery/dist/jquery.slim.min.js"></script>
|
||||
<script src="../../dist/dom/eventHandler.js"></script>
|
||||
<script src="../../dist/dom/selectorEngine.js"></script>
|
||||
<script src="../../dist/dom/data.js"></script>
|
||||
<script src="../../dist/util.js"></script>
|
||||
<script src="../../dist/button.js"></script>
|
||||
</body>
|
||||
|
Reference in New Issue
Block a user