留言板
aui checkBox Click Event
Hi there,
I'm trying to detect the onclick event for a checkbox using aui, but has not been able to.
Liferay 6.1 CE
The code does not work, the alert is never displayed
Thank you for your help
I'm trying to detect the onclick event for a checkbox using aui, but has not been able to.
Liferay 6.1 CE
<aui:input name="international" id="international" type="checkbox" value="international"></aui:input>
<aui:script use="aui-node">
AUI().ready('aui-base','node', 'event', function (A) {
A.one('#international').on('click',
function() {
alert('demo');
});
});
</aui:script>
The code does not work, the alert is never displayed
Thank you for your help
Hi Alexis,
try with code below.
aui checkbox elemennt adds Checkbox prefix to id.
try with code below.
A.one('#internationalCheckbox').on('click', function(){alert("clicked");});
aui checkbox elemennt adds Checkbox prefix to id.
I tried, but I generate javascript error
Chrome error
Uncaught TypeError: Cannot read property 'on' of null
Firefox Error
TypeError: b.one(...) is null
any idea?
Tranks
Chrome error
Uncaught TypeError: Cannot read property 'on' of null
Firefox Error
TypeError: b.one(...) is null
any idea?
Tranks
Hi,
You can add Cssclass selector and trigger onChange event as below:
Can you try below?
HTH!
You can add Cssclass selector and trigger onChange event as below:
<aui:input name="international" id="international" type="checkbox" value="international" cssclass="test"></aui:input>
Can you try below?
A.one('.test .aui-field-input-choice:checkbox').on('change',function(){alert("test");});
HTH!
Sorry, forgot to mention. aui tags also append <portlet:namespace/> to it.
Try this:
Try this:
A.one('#<portlet:namespace />internationalCheckbox').on('click', function(){alert("clicked");});