EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: aswzen on December 17, 2015, 03:03:22 AM



Title: Integrate switchbutton with <label>
Post by: aswzen on December 17, 2015, 03:03:22 AM
Can you make switchbutton integrates with label?

So basically when the switchbutton inside the label, we can toggle it by clicking the label.

I try to make it manually, but there is no toggle method in documentation
Code:
<label onClick="$('#EMAIL_EQU').switchbutton('check');">
     <input class="easyui-switchbutton" id="EMAIL_EQU" data-options="onText:'Yes',offText:'No'"> Send Equipment Revision Notification
</label>

Can you make it more simple?

Thank you in advance  :)


Title: Re: Integrate switchbutton with <label>
Post by: jarry on December 17, 2015, 11:43:40 PM
Please call the 'makeClickable' function to make switchbutton work inside a label.
Code:
function makeClickable(buttons){
$(buttons).each(function(){
var b = $(this).data('switchbutton').switchbutton;
$(this).bind('click', function(){
b.triggerHandler('click');
return false;
});
b.bind('click', function(){
return false;
});
})
}

Code:
<label>
     <input class="easyui-switchbutton" id="EMAIL_EQU" data-options="onText:'Yes',offText:'No'"> Send Equipment Revision Notification
</label>
<script>
$(function(){
makeClickable('#EMAIL_EQU');
})
</script>