How can I execute a javascript function when clicking an action?

Hi,

I have an action of type “bare_link”, and I would like to execute a javascript function when the user clicks on the link, so I can register the event on the Audit Logs.

I've seen that bare_link type actions are supposed to have a property called “onclick” to execute JS functions: http://showcase.nuxeo.com/nuxeo/layoutDemo/bare_linkAction

I've tried adding the onclick property in two ways, but none of them worked.

Test 1:

<action id="actionId" link="#{actionBean.method()}" type="bare_link"
            label="label" icon="/icons/icon.png" order="150" onclick="alert('AAAA')">
      <category>BLOB_ACTIONS</category>
</action>

Test 2:

<action id="actionId" link="#{actionBean.method()}" type="bare_link"
            label="label" icon="/icons/icon.png" order="150">
    <category>BLOB_ACTIONS</category>
    <properties>
        <property name="onclick">alert('AAAA')</property>
    </properties>
</action>

I have searched in the Nuxeo code and I have seen that the property is never used.

Does it work? Am I doing something wrong? Is there any other way to achieve what I want?

Thank you very much in advance, Ibai

1 votes

1 answers

286 views

ANSWER



For the moment I've changed the action type. I've created an action of type “template”, so I am in control of what I want to execute when the user clicks on the link. Anyway, I would love to know if the onclick property works and I am doing it wrong. Regards,

0 votes