Foren

How to call onClick() in <liferay-ui:custom-attribute>

thumbnail
Pradeep Pandey, geändert vor 11 Jahren.

How to call onClick() in <liferay-ui:custom-attribute>

New Member Beiträge: 6 Beitrittsdatum: 19.07.12 Neueste Beiträge
Plz anyone tell me , how to call JavaScript function when i clicked on radio button in Liferay custom attribute.
See below, I created one custom attribute " Usertype" that having two radio button.
1-Doctor
2-patient
I want to call java script function by using 'on Click()' event when i click on any button. but following code giving error

<liferay-ui:custom-attribute
className="<%= User.class.getName() %>"
classPK="<%= 0 %>"
editable="<%= true %>"
label="<%= true %>"
name="Usertype" onClick="eventCheck()"/>

ERROR:->Attribute onClick invalid for tag custom-attribute according to TLD
thumbnail
Tejas Kanani, geändert vor 11 Jahren.

RE: How to call onClick() in <liferay-ui:custom-attribute>

Liferay Master Beiträge: 654 Beitrittsdatum: 06.01.09 Neueste Beiträge
Hi Pradeep,

You are right. There is no "onClick" attribute for liferay-ui:custom-attribute.
If possible, try to bind onclick event dynamically on your element using jQuery.

Thanks,
Tejas
thumbnail
Pradeep Pandey, geändert vor 11 Jahren.

RE: How to call onClick() in <liferay-ui:custom-attribute>

New Member Beiträge: 6 Beitrittsdatum: 19.07.12 Neueste Beiträge
Hi Tejas.

would you like to explain ,how to bind onclick event dynamically using jQuery in this scenario.

Thanks,
pradeep
thumbnail
Tejas Kanani, geändert vor 11 Jahren.

RE: How to call onClick() in <liferay-ui:custom-attribute>

Liferay Master Beiträge: 654 Beitrittsdatum: 06.01.09 Neueste Beiträge
Sorry for late reply.
Can you share the html generated through <liferay-ui:custom-attribute> tag ?
It might help.

Thanks,
Tejas
thumbnail
Manish Kumar Jaiswal, geändert vor 11 Jahren.

RE: How to call onClick() in <liferay-ui:custom-attribute>

Regular Member Beiträge: 153 Beitrittsdatum: 25.11.08 Neueste Beiträge
This is a simple example of onclick on tag .

Regards
Manish
thumbnail
Alireza Zare, geändert vor 11 Jahren.

RE: How to call onClick() in <liferay-ui:custom-attribute>

Regular Member Beiträge: 110 Beitrittsdatum: 03.09.10 Neueste Beiträge
I would do it this way:
...
<aui:button name="button" onClick="<portlet:namespace />doSomthing(); return false;" value="Do somthing" />
...
<aui:script>
function <portlet:namespace />doSomthing() {
......
}
</aui:script>

Regards,
Alireza