2014-09-02 33 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 
     } 
      }); 
     } 
    }); 
相關問題