Two Functions in Click Event - One to a Javascript Function and One Calling Server Connect?

Hi Wappler Community,

This might be a super simple question, but I’ve been struggling with this for a while.

I have a button which a Click dynamic event attached, I can have either a Server Connect call which looks like this:

switchDownload.load({productidfromdownload: id})
^ this works perfectly and calls the server connect function.

I have a custom javascript function which creates a custom iFrame and I have replaced the OnClick function with this:

setIframe(this, ‘download.php?srcurl={{fileName}}’)
^ this also works correctly.

But how can I call both of these at the same time? If I put them together in the Click dynamic event I get all sorts of errors like and I’ve tried all manner of {} and ‘’ and “” combinations to try and get the function calls through correctly.

The errors are usually like ReferenceError: id is not defined

No idea how to send the function calls together through a Click dynamic event.

Also, I should note that I can call as many dynamic data functions as I like using the Wappler UI, I’m just having trouble with calling a custom JS function at the same time as another server connect function.

I have a feeling it just needs to be formatted a certain way that Wappler can understand but I’m not sure about the correct way of achieving this.

Thanks for the help in advance.

Cheers and Merry Xmas.

1 Like

Give this a try:

{{switchDownload.load({productidfromdownload: id})}}; setIframe(this, ‘download.php?srcurl={{fileName}}’)

Sorry, I’m not at a computer to test!

—Ken

Wow, thank you so much @mebeingken - that worked straight away. I think my problem was I also wrapping the end statement as well, good knowledge for the future, thank you.

1 Like

Happy to help!

And Kudos on a great question with all the details needed to solve quickly!

1 Like