377
Views
10
Comments
Solved
Widget_Click Not Working After Ajax Refresh LinkĀ 
Question

It seems that after performing an ajax refresh of a link, the Widget_Click server action doesn't seems to be working as it is anymore. As the link has a input parameter, I need to refresh the link so that I am able to pass the updated input parameter to the next destination. However, it doesn't seems to work.

2020-02-28 09-46-54
Eduardo Jauch
Solution

Hi Jianlong,

I'm not sure, but I think the Ajax will happen only at the END of the action, and at this point, the Click already as bind to the old link id.

If that is the case (I would have to test this, but will not have time until next year ;) rs), a possible (ugly) workaround would use a specific class (for example), and run a JavaScript instead of the Click, something like this: "$('.myclass').click();".

This would avoid the problem of the changed ID.

Cheers.

UserImage.jpg
Jianlong Lin

Eduardo Jauch wrote:

Hi Jianlong,

I'm not sure, but I think the Ajax will happen only at the END of the action, and at this point, the Click already as bind to the old link id.

If that is the case (I would have to test this, but will not have time until next year ;) rs), a possible (ugly) workaround would use a specific class (for example), and run a JavaScript instead of the Click, something like this: "$('.myclass').click();".

This would avoid the problem of the changed ID.

Cheers.

Hi Eduardo,

Thanks for your advice. It worked. 


2020-07-21 19-28-50
Rajat Agrawal
Champion

Hi Lin,

If you don't have ajax refresh then it is working for you or not?


Thanks

Rajat

UserImage.jpg
Jianlong Lin

Rajat Agrawal wrote:

Hi Lin,

If you don't have ajax refresh then it is working for you or not?


Thanks

Rajat


Previously, without the ajax refresh it is working fine. 

2020-07-21 19-28-50
Rajat Agrawal
Champion

It means if you remove ajax refresh it is working fine for you. Please can you send your OML may be you are doing small mistake.


Thanks,

Rajat Agrawal

UserImage.jpg
Jianlong Lin

I found out that the id of the link will be changed after ajax refresh which may be causing the problem. However, for Widget_Click, it should be getting the new widget id. If it's not, how can I get the updated widget id to be the input parameter for Widget_Click? 

2020-07-21 19-28-50
Rajat Agrawal
Champion

Jianlong Lin wrote:

I found out that the id of the link will be changed after ajax refresh which may be causing the problem. However, for Widget_Click, it should be getting the new widget id. If it's not, how can I get the updated widget id to be the input parameter for Widget_Click? 


Hi Jian,


We never use ID because ID generated new everytime. You need to give class instead of id when we use javascript. Do one thing just give name to your link like Rajat and then call link name.id like Rajat.Id in the click widget it will work.



Thanks,

Rajat Agrawal

2020-02-28 09-46-54
Eduardo Jauch
Solution

Hi Jianlong,

I'm not sure, but I think the Ajax will happen only at the END of the action, and at this point, the Click already as bind to the old link id.

If that is the case (I would have to test this, but will not have time until next year ;) rs), a possible (ugly) workaround would use a specific class (for example), and run a JavaScript instead of the Click, something like this: "$('.myclass').click();".

This would avoid the problem of the changed ID.

Cheers.

UserImage.jpg
Jianlong Lin

Eduardo Jauch wrote:

Hi Jianlong,

I'm not sure, but I think the Ajax will happen only at the END of the action, and at this point, the Click already as bind to the old link id.

If that is the case (I would have to test this, but will not have time until next year ;) rs), a possible (ugly) workaround would use a specific class (for example), and run a JavaScript instead of the Click, something like this: "$('.myclass').click();".

This would avoid the problem of the changed ID.

Cheers.

Hi Eduardo,

Thanks for your advice. It worked. 


UserImage.jpg
Jianlong Lin

Hi Rajat,

Attached is the oml file. 

Widget_Click.oml
2020-02-28 09-46-54
Eduardo Jauch

@Rajat,

When you use widget.id you are using the ID of the widget...

Cheers.

2020-07-21 19-28-50
Rajat Agrawal
Champion

@Eduardo - Yups correct.. They are refreshing the link so new ID generating everytime. 


Thanks,

Rajat

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.