3

如何在 AlloyUIi 中获取 Liferay AUI taglib 复选框选中值?

<aui:input type="checkbox" ></aui:input>
4

3 回答 3

2

您可以通过 attr 方法获取复选框的选中值,例如A.one("#id").attr('checked')其中 id 将是复选框的元素 id。

于 2014-09-02T13:35:37.590 回答
2

我已经开发了获取单个复选框值的完整解决方案,它可能对其他 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
            }
        });
    });
});
于 2014-12-10T12:51:44.187 回答
1
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
        }
            });
        }
    });
于 2017-02-13T12:54:27.143 回答