jQuery Ajax call for buttons on a list
- by lloydphillips
I have a list of data that i have in a view from an asp.net mvc application. It's a list of stock and I have two images (a plus and a minus) on the end of each row which will allow me to increase or decrease stock quantity. It works fine at present with a call to the mvc action but since the list is long I want to use jQuery and AJAX to have the call go without a refresh. I want to do this with unobtrusive javascript so don't want onclick handlers on my images. Since I'm just starting out with jQuery I have no idea how I can iterate all the images and add the function. Here are the images with the form tags as they stand:
<td>
<% using (Html.BeginForm("Increase", "Stock", new { Id = item.StockId }))
{%>
<input type="image" src="/Content/Images/bullet_add.png" style="margin-left:20px;" /> <% } %>
</td>
<td><% using (Html.BeginForm("Decrease", "Stock", new { Id = item.StockId }))
{%>
<input type="image" src="/Content/Images/bullet_delete.png" style="margin-left:10px;" /><% } %>
</td>
Can anyone help me out a little?
Many thanks.
Lloyd