Widget_Click Not Working After Ajax Refresh Link

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.

Hi Lin,

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


Thanks

Rajat

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. 

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

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? 

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.

Solution

Hi Rajat,

Attached is the oml file. 

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

@Rajat,

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

Cheers.

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


Thanks,

Rajat

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.