AjaxOptions OnSuccess callback with parameter not working

I am trying to use AjaxOptions.OnSuccess to call a javascript function and pass a parameter to it. I can name the base function without parameters without problems, it is just passing parameters.

Here is my JS function:

<script type="text/javascript"> function removeRow (itemId) { alert(itemId); } </script> 

And my Razor AjaxOptions ad:

 New AjaxOptions With {.OnSuccess = "function(){removeRow(" + item.Id.ToString + ");}"} 

On the client side, the link is as follows:

 <a data-ajax="true" data-ajax-success="function(){removeRow(3);}" href=... 

Any idea what I'm doing wrong?

Thanks!

+6
source share
1 answer

Try the following:

 New AjaxOptions With {.OnSuccess = String.Format("removeRow({0})", item.Id) } 
+4
source

Source: https://habr.com/ru/post/891828/


All Articles