Ad

How Do You Use JQuery To Simplify Your MVC Views?

- 1 answer

I have found jQuery to be a great tool to simplify my MVC Views.

For example, instead of including complicated logic to add alternating styles to my tables I just do this...

$(document).ready(function() {
   $("table.details tr:odd").addClass("detailsAlternatingRow");
   $("table.details tr:even").addClass("detailsRow");                          
});

Do you know of any other good uses of jQuery to slim down the logic in my MVC View?

Ad

Answer

MVC Framework has a JsonResult that can be very nice to eliminate server round trips and might be able to get rid of some of the logic in your view page. I wrote a tutorial on this available at :

http://www.dev102.com/2008/08/19/jquery-and-the-aspnet-mvc-framework/

Ad
source: stackoverflow.com
Ad