views:

361

answers:

11

From an ASP.NET MVC perspective, what do you use jQuery for?

Apart from UI "flair" - things like fading colours and pretty animations.

Things I can immediately think of include pop-up calendars and modal popup dialogs, but there must be more...

Edit

I am interested in jQuery uses for things that ASP.NET MVC does not do out of the box, or things that jQuery makes easier/simpler.

A: 

Beyond UI sugar? Mostly for AJAX get and post here.

Jarrett Meyer
+2  A: 

I also find it useful for manipulating the dom tree. For example, adding onclick events to a lot of objects is much easier. After using it it becomes hard to see how anyone could want to manipulate the dom any other way.

If I am using it in a site (i.e. already including the file), I use it for Ajax as well rather than writing (or using) my own class.

Yacoby
A: 

Better tooltips is one thing that gets a lot of use at work. Show a hidden div when hovering over something. Don't know if that falls into the "flair" category.

smack0007
+2  A: 

jQuery is fundamentally a cross-browser DOM parsing, manipulation and event handling framework and that is primarily what I use it for. All of the eye candy stuff is built on top of this core functionality.

And of course the AJAX too. However there is nothing especially revolutionary here that wasn't covered before in previous 'flavour of the month' frameworks like prototype etc.

mysomic
A: 

$.Ajax, to makes requests and posts. Also to handle the insertion of the returned data to places on the page. The selectors are so powerful for this kind of thing:

$('.textbox').val() //to obtain data
$('.textbox').val(somedata) //to insert data

Wonderful

Damien
A: 

I'm using jQuery (AJAX, Dialogs, Effects, UI) heavily in the site administration parts.

eu-ge-ne
+1  A: 

I use it for pre-loading more content than is actually shown - if I have a "tabbed" page, I load the contents of all tabs at once, and then show/hide the different sections (and style the tab menus with css classes) using jQuery.

Tomas Lycken
A: 

Not directly a .net MVC aspect but just not having to worry (nearly as much) about my client side scripts working in different browsers is a biggie as far as I'm concerned.

CodeBadger
+2  A: 

Usability. For instance, you always validate on the server side, but if you can use JavaScript to save a long (relatively) wait for sever side validation, you can improve usability. Instead of making the user wait for the server side validation to tell them that their email address is not valid, check it first with the JavaScript, then when it appears they've entered it correctly, check it again on the server.

Similarly, you can add hints to your forms. For instance, say you have a date field where the user needs to enter their birthday. Using jQuery (or any JavaScript for that matter), you can pre-populate the field with the format you want them to enter their date in, say in a lighter text color, and in italics. When the birthday form field gets focus, you can use jQuery (or any JavaScript) to clear out the hint and accept their real input.

I also like how simple jQuery makes Ajax - which can also make your site more usable. Don't make the user wait for another request and page load when you can use Ajax to give the user the information they want on the page they're currently on.

I've been finding that the best use of jQuery for me personally, has been to increase the usability of the site by trying to minimize wait times, page requests, and just general annoyances, like having to fill out the form again after it didn't validate successfully.

Hooray Im Helping
+3  A: 

Some of the things I use jQuery for are:

  • simplified AJAX
  • client-side validation
  • forms that have application like behavior (ex changing the visible form elements based on a dropdown)
  • interactive and dynamic menus
  • client-side sorting
  • dynamic textareas that grow as you type
  • drag'n'drop
  • integrating with a flash based multi-file uploader
Todd Smith
+1  A: 

Client-side model validation in ASP.NET MVC. It's very easy to generate a JSON ruleset for jQuery on the server side (for example using Data Annotation attributes) and let jQuery.validate consume it, allowing for simple re-use of the same rules on the server validation side.

bzlm