Ajaxing a link in a table

Posted by Colin Desmond on Stack Overflow See other posts from Stack Overflow or by Colin Desmond
Published on 2010-03-24T00:02:58Z Indexed on 2010/03/24 0:13 UTC
Read the original article Hit count: 700

Filed under:
|
|

I have a table of results in an ASP.Net MVC page where the last column is an View Details link. I want to have the user click the View Details link and an AJAX method be called to open the results in floating dialog.

What I am struggling with is how to link the AJAX call to the link in the results table. I was using a link which embedded the ~/ControllerName/ViewDetails/InstanceId link directly in it. Clicking it took the user to a new page and it is this behaviour I want to replace with an AJAX call and a dialog window.

Now I want to attach a jQuery handler to the link to trigger the AJAX call and I can't see how to do this other than write an jQuery handler for each row in the results table. There must be a way to mark the link as an ViewDetails link (using a class?) and attach the jQuery click handler to all instances of type class ViewDetails.

© Stack Overflow or respective owner

Related posts about asp.net-mvc

Related posts about AJAX