cancel
Showing results for 
Search instead for 
Did you mean: 

Custom client-side JavaScript not called

pkanuri
Champ on-the-rise
Champ on-the-rise
Apologies , code was missing in my original post.

Hi,

I have been trying , in vain, for 3 days now to call a custom client side jS function from an action.

In my share-config-custom.xml


<config evaluator="string-compare" condition="DocLibActions">
      <actions>
       <action id="document-archive" type="javascript" label="Archive">
            <param name="function">onActionChangeTypo</param>
         <permissions>
                <permission allow="true">Write</permission>
            </permissions>
            <param name="action">expire-artefact</param>
            <param name="successMessage">Artefact successfully expired</param>
            <param name="failureMessage">Failed to Expire artefact</param>
         </action>
      </actions>
                      ….
</config>

<!– Document Library Custom Code config section –>
   <config evaluator="string-compare" condition="DocLibCustom" replace="true">
       
         <dependencies>
            <!–css src="my-custom-action.css" /–>
            <js src="components/documentlibrary/my-custom-action.js" />
         </dependencies>
     
   </config>

I am able to view the "action" menuitem in the "Document Actions" . But clicking it does NOT call the function in my-custom-action.js that I had placed under ../tomcat/webapps/share/components/documentlibrary/my-custom-action.js (my-custom-action-min.js as well).

Here is the content of my-custom-action.js. It is quite straightforward. Just pop up a dialog (for now)

(function() {
    YAHOO.Bubbling.fire("registerAction",
    {
        actionName: "onActionChangeTypo",
        fn: function custom_onActionChangeTypo(file) {
           var displayPromptText = this.msg("Do you want to expire this artefact?", file.displayName);
        }
    });
})();



I am frustrated that my JS function isn't getting called at all. I've tried changing the paths in the dependencies but no luck.

Kindly let me know if I am missing something.

Really appreciate any help.

Thanks,
Phani
1 ACCEPTED ANSWER

niketapatel
Star Contributor
Star Contributor
Hi, everything looks OK. Can you try with below js code. Remove function() from top.


    YAHOO.Bubbling.fire("registerAction",{
        actionName: "onActionChangeTypo",
        fn: function custom_onActionChangeTypo(file)
      {
           var displayPromptText = this.msg("Do you want to expire this artefact?", file.displayName);
         alert(displayPromptText);
        }
    });


View answer in original post

2 REPLIES 2

niketapatel
Star Contributor
Star Contributor
Hi, everything looks OK. Can you try with below js code. Remove function() from top.


    YAHOO.Bubbling.fire("registerAction",{
        actionName: "onActionChangeTypo",
        fn: function custom_onActionChangeTypo(file)
      {
           var displayPromptText = this.msg("Do you want to expire this artefact?", file.displayName);
         alert(displayPromptText);
        }
    });


Hi Niketa,

Thanks very much for the response.
I tried it and it worked.

Have a nice day!

Thanks,
Phani