views:

65

answers:

3

Hello Everyone, I have a view that uses a javascript callback to reload a partial view. For whatever reason the contents of the partial class do not refresh even though i can step through the entire process and see the page being recalled and populated. Any reason why the page would not display?

Code is as follows:

<div id="big_image_content">
                    <% Html.RenderPartial("ZoomImage", Model); %>
</div>

This link should reload the div above:

<a href="javascript:void(0)" onclick="$('#big_image_content').load('/ShopDetai/ZoomImage?image_item=something&image_room_scene=something&category=something');"
title="<%= shape.Shape %>" alt="<%= shape.Shape %>">
  <img src="http://images.rugs-direct.com/&lt;%= shape.Image.ToLower() %>" width="40"   alt="<%= shape.Shape %>">
</a>

partial view(ZoomImage.ascx) simplified for now, but still doesn't load:

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<RugsDirect.Data.ItemDetailsModel>" %>

<%= Model.Category.ToLower()%>

And finally the controller side of things:

    public ActionResult ZoomImage(string image_item, string image_room_scene, string category)
    {
        try {
            ItemDetailsModel model = GetMainImageContentModel(image_item, image_room_scene, category);


            return PartialView("ZoomImage", model);
        }
        catch (Exception ex)
        {
            //send the error email
            ExceptionPolicy.HandleException(ex, "Exception Policy");

            //redirect to the error page
            return RedirectToAction("ViewError", "Shop");
        }
    }

Again, i can step through this entire process and all seems to be working accept for the page not reloading. I can even break on the <%= Model.Category.ToLower()%> of the partial view, but it will not be displayed.

Thanks in advance, Billy

A: 

Try changing

.load('/ShopDetai/ZoomImage);

Which has a syntax error as well too

.load('/ShopDetai/ZoomImage?r='+Math.random());

The Math.random() forces a fresh page even with proper caching in place.

EDIT:

If you change it to

.load('/ShopDetai/ZoomImage?r='+Math.random(), function(response, status, xhr) {
  if (status == "success" ) alert("got the page");
});

Do you get a popup ?

Martijn Laarman
Sorry, i edited my question. Just a typo no syntax error or it wouldn't make it to the controller in the first place. Giving your answer a test as we speak.
Billy Logan
No luck with this. Does the same thing. Runs through the entire code(even the on line on the partial view) and then displays nothing.
Billy Logan
I updated it so that it specifies a callback handler, try fiddling with this to see if its even triggering.
Martijn Laarman
I do get the message. Not sure it has something to do with this piece of the code as i make it back to the controller just fine.
Billy Logan
One other thing to note with this. I took the model out of the equation and all works fine. Just set a viewdata object on the intial load and then reset it on the javascript reload. Will have to keep digging i need the model included.
Billy Logan
A: 

I just set up your exact situation locally and everything runs fine for me. Granted my model contains a random number generator instead of whatever yours is doing. I also have it working without the random url extension to beat caching.

My question to you is, what exactly is the effect you are trying to produce? What information should change, what does it start as and what do you expect it to change to? You have listed a bunch of code here and said it is broken, but not what you expect to be happening other than "updating".

NickLarsen
Yeah, There is actually an image that changes on the partial class. Hence the ZoomImage name. My point with this illustration remains the same though. The <%= Model.Category.ToLower()%> vanishes after reloading the model through the call back. Even though you can plainly see it populated throughout debugging all the way down to the actual stepping through of the ZoomImage.ascx file.
Billy Logan
A: 

After digging and digging i gradually re-applied all of my script and everything is working like it should be. The problem came to be that one of my parameter values had a space. After removing the space everything worked.

Billy Logan
ohh yea, we would have never seen that with the original post.
NickLarsen
not unless i had given you the values of the variables. Just didn't think about that. thanks.
Billy Logan