的文档说的按钮可以被格式化为开或关切换,但给定的例子仅是
<div class="ui toggle button">
Vote
</div>
这自然是行不通的。对示例源代码的检查显示,active
已以编程方式添加了一个类。
我可能缺少一些简单的东西,但是如何创建像该示例所示的切换按钮?指定切换内容的语法是什么?
下面的代码正在发挥作用:
semantic.button = {};
// ready event
semantic.button.ready = function() {
// selector cache
var
$buttons = $('.ui.buttons .button'),
$toggle = $('.main .ui.toggle.button'),
$button = $('.ui.button').not($buttons).not($toggle),
// alias
handler = {
activate: function() {
$(this)
.addClass('active')
.siblings()
.removeClass('active')
;
}
}
;
$buttons
.on('click', handler.activate)
;
$toggle
.state({
text: {
inactive : 'Vote',
active : 'Voted'
}
})
;
};
// attach ready event
$(document)
.ready(semantic.button.ready)
;
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句