Nate Pet
Nate Pet

Reputation: 46222

JQuery .load(), PartialView, MVC

I am using MVC3 with Jquery's .load() with a PartialView().

From my jquery, I am doing the following:

      $("#stlist").load('@Url.Action("KitEdit","Kit")' + '?id=' + id+ '&pick=' + pick)

The partial view is called from the KitEdit action.

I was wondering if there is another way of loading a partial view besides the .load()?

I am getting some wierd behaviors where once the .load is done, some of the buttons don't work the second time.

Upvotes: 1

Views: 2221

Answers (2)

mreyeros
mreyeros

Reputation: 4379

If your buttons are using jquery click events you may to modify them to use .on syntax when defining the click behavior.

Upvotes: 1

nikeaa
nikeaa

Reputation: 1047

Is the partial view displayed without refreshing the entire page? If so, you need to add some jQuery that will run after the partial view is loaded to hook up all of the controls in the partial view. What I would suggest is adding a complete function (http://api.jquery.com/load/) to your jQuery .load() call like this:

 $("#stlist").load('@Url.Action("KitEdit","Kit")' + '?id=' + id+ '&pick=' + pick, Complete);

Then the complete function would hook up all the controls from the partial view.

Hope this helps!

Upvotes: 2

Related Questions