views:

37

answers:

2

How can I attach jquery on an ASP.NET MVC partial load. I've a form rendered in a partial that has some jquery attached, but that code is not running at all

A: 

That depends on how you load your partial - MS Ajax or jQuery .ajax(). For example, jQuery (as far as I remember) only evaluates scripts in head tag of the loaded partial (I may be wrong, though).

So you really need to provide your code - how do you load partial and what it does contain.

queen3
A: 

If your partial view is being loaded via Ajax you will need to use the jQuery "live" method. This method allows you to bind events to DOM elements that will be added to the page via Ajax.

Steve Horn