How to use Widget_Click for a navigate link

Hi,

I am new to outsystems, can anyone tell me what to use instead of widget_click for any link having navigate function.

I have tried 

1."$("+ Widget_Id +").trigger('click');"

2."$('#" + Widget_Id + "').click();"

in RunJavaScript but to no avail as i have Widget_Id as a variav=ble in my function.

Please help me as i am stuck in this scenario.

Thanks in advance.



Hello Ishan,
may I ask how are you calling that RunJavaScript action? 

Take in mind that the widget_click have these limitations above.
Best Regards

Hi Ishan,

I could be wrong, but that looks like jQuery. Have you imported the min.js file for jQuery in your application?


Another thing you could try that does not use jQuery is "document.getElementById(' "+ Widget_Id +" ').click();" 

The .click(); function should work normally on a button or link with any method - Navigate, Submit, and Ajax Submit.

Hi Ishan,

You can achieve the same result with this javascript:

window.location = $('#' + WidgetId).attr('href');

This doesn't trigger the link's click handler, but redirects the browser to the link's destination.

Hi Ishan,

Use this way to call button click event instead of widget_click action-

Line - Link Or Button Name - "HdnCurrency"


SyntaxEditor Code Snippet

"$('#"+HdnCurrency.Id+"').click();"

Paulo Zacarias wrote:

Hello Ishan,
may I ask how are you calling that RunJavaScript action? 

Take in mind that the widget_click have these limitations above.
Best Regards

Hi,

I am calling RunJavaScript action same as widget_click action.

Also, i need to click on navigate link using RunJavaScript. After reading all the replies,

I think solution will work if i convert all links to buttons of navigate action but there are multiple links for which i use this function. Is there any other way to solve this situation, do tell.


Aurelio Junior wrote:

Hi Ishan,

You can achieve the same result with this javascript:

window.location = $('#' + WidgetId).attr('href');

This doesn't trigger the link's click handler, but redirects the browser to the link's destination.

I will surely try this approach. Thanks for sharing. 


Monique de Vos wrote:

Hi Ishan,

I could be wrong, but that looks like jQuery. Have you imported the min.js file for jQuery in your application?


Another thing you could try that does not use jQuery is "document.getElementById(' "+ Widget_Id +" ').click();" 

The .click(); function should work normally on a button or link with any method - Navigate, Submit, and Ajax Submit.

I will surely try this approach. Thanks for sharing.


Solution

Hi Ishan, 

When triggering the 'AlreadyDeletedContent..." screen action, you can go ahead and change the RunJavaScript action by a Widget_Click that clicks a button that has its method as AJAX submit and calls another screen action that ends with a navigation node instead of the 'End' node you have in this image above. 

Best Regards

Solution

Paulo Zacarias wrote:

Hi Ishan, 

When triggering the 'AlreadyDeletedContent..." screen action, you can go ahead and change the RunJavaScript action by a Widget_Click that clicks a button that has its method as AJAX submit and calls another screen action that ends with a navigation node instead of the 'End' node you have in this image above. 

Best Regards


Hi Paulo,

Approach suggested by you worked as a charm in my scenario.

Thanks,

Ishan


Hi Ishan, 

I'm glad it worked as you expected! 

Best Regards