Foros de discusión

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

thumbnail
Pradeep Pandey, modificado hace 11 años.

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

New Member Mensajes: 6 Fecha de incorporación: 19/07/12 Mensajes recientes
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, modificado hace 11 años.

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

Liferay Master Mensajes: 654 Fecha de incorporación: 6/01/09 Mensajes recientes
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, modificado hace 11 años.

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

New Member Mensajes: 6 Fecha de incorporación: 19/07/12 Mensajes recientes
Hi Tejas.

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

Thanks,
pradeep
thumbnail
Tejas Kanani, modificado hace 11 años.

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

Liferay Master Mensajes: 654 Fecha de incorporación: 6/01/09 Mensajes recientes
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, modificado hace 11 años.

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

Regular Member Mensajes: 153 Fecha de incorporación: 25/11/08 Mensajes recientes
This is a simple example of onclick on tag .

Regards
Manish
thumbnail
Alireza Zare, modificado hace 11 años.

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

Regular Member Mensajes: 110 Fecha de incorporación: 3/09/10 Mensajes recientes
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