如何在 AlloyUIi 中获取 Liferay AUI taglib 复选框选中值?
<aui:input type="checkbox" ></aui:input>
如何在 AlloyUIi 中获取 Liferay AUI taglib 复选框选中值?
<aui:input type="checkbox" ></aui:input>
您可以通过 attr 方法获取复选框的选中值,例如A.one("#id").attr('checked')
其中 id 将是复选框的元素 id。
我已经开发了获取单个复选框值的完整解决方案,它可能对其他 AUI 脚本开发人员有所帮助
AUI().ready('aui-node',function(A) {
A.all(':checkbox').each(function() {
this.on('click', function(event) {
var checkBoxStatus = A.all(':checked');
if(checkBoxStatus.attr('checked') == 'true') {
// your conditional code
}
else {
// your conditional code
}
});
});
});
AUI().ready('aui-base','event','node', function(A){
if(A.one("#<portlet:namespace />termsAndCondition")){
A.one('#<portlet:namespace/>termsAndConditionCheckbox').on('click',function(e){ // it requires Checkbox as prefix in AUI`enter code here`
if(A.one("#<portlet:namespace/>termsAndConditionCheckbox").attr('checked')){
// your code
}else{
// your code
}
});
}
});