I am trying to use AjaxOptions.OnSuccess to call a javascript function and pass a parameter to it. I am able to call a basic function with no parameters without a problem, it's just the parameter passing.
Here is my JS function:
<script type="text/javascript">
function removeRow (itemId) {
alert(itemId);
}
</script>
And my AjaxOptions declaration in razor:
New AjaxOptions With {.OnSuccess = "function(){removeRow(" + item.Id.ToString + ");}"}
On the client side the link appears like this:
<a data-ajax="true" data-ajax-success="function(){removeRow(3);}" href=...
Any idea what I'm doing wrong?
Thanks!
Try this:
New AjaxOptions With {.OnSuccess = String.Format("removeRow({0})", item.Id) }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With