Published on InterSystems Developer Community (https://community.intersystems.com)

Home > Calling javascript method from Zen method, with parameters

Question
Laura Cavanaugh · Aug 11, 2016

Calling javascript method from Zen method, with parameters

I'm running into difficulty calling a javascript method from a Zenmethod.  I pass in a parameter, but in the javascript method the parameter is undefined.  Here is the code:

...

<button id="btnSave" caption="Save " onclick="zenPage.doSave();" controlClass="bButton"/>

...

Method doSave() [ ZenMethod ]
{

          If (..ID = "AddNew"){
                    //do save code here                   
                    &js<zenPage.doAddNew();>      //this works just fine, but there's no parameter

          }Else{
                    //do update code here

                    //call javascript method from ZenMethod
----->         &js<zenPage.doReturn('1');>     //this calls doReturn, but the parameter '1' is undefined when it gets there
                    //do %page.doReturn("1")         //NO
}

 

ClientMethod doReturn(silent) [ Language = javascript ]
{
           alert('silent = ' + silent)     //shows as undefined

}

 

 

I did not choose to set the methods up like this; they exist already.  I just need to call the doReturn method, which already exists as a javascript method, in order to return to another page. 

 

 

If the ZenMethod doSave were a javascript method, would it work better?

Thanks,

Laura

#JavaScript #ZEN #Caché

Source URL:https://community.intersystems.com/post/calling-javascript-method-zen-method-parameters