2014-09-02 57 views
1

如何获取合金中的Liferay AUI taglib复选框选中值?如何获取合金中复选框的检查值

<aui:input type="checkbox" ></aui:input> 
+1

你可以通过attr方法得到它,如A.one(“#id”)。attr('checked')其中id将是复选框的元素ID。 – 2014-09-02 08:55:42

+0

@PankajKathiriya您可以在答案部分而不是评论部分回答吗?你会感谢我,如果你做到了:-) – 2014-09-02 11:50:59

+0

@PrakashK再次感谢普拉卡什! :) – 2014-09-02 13:36:10

回答

1

我已经开发了完整的解决方案对于获得单个复选框值,这可能有助于其他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 
     } 
    }); 
}); 

});

2

你可以通过ATTR方法复选框的选中值一样A.one("#id").attr('checked')其中id将复选框的元素ID。

+2

**重要注意事项**:Liferay目前将“复选框”连接到'id'属性,无论是明确提供的还是从'name'属性生成的。 – Origineil 2014-09-02 15:10:48

+0

正确。这需要注意 – 2014-09-02 15:26:02

0
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 
     } 
      }); 
     } 
    });