Does anyone know why jquery dialog is showing stale content on ajax update ?

Posted by oo on Stack Overflow See other posts from Stack Overflow or by oo
Published on 2010-04-27T14:25:36Z Indexed on 2010/04/27 16:33 UTC
Read the original article Hit count: 200

I have a series of links and when i click on a link i want to show a dialog with detail information. This detail is returned from an jquery ajax request.

I am using the following code below to show a partial result through ajax onto a jquery dialog.

Here is the jquery code:

$(document).ready(function() {

 $('a.click').live('click', function() {

    var url = '/Tracker/Info?id=' + $(this).attr("id");

    var dialogOpts = {
        modal: true,
        bgiframe: true,
        autoOpen: false,
        height: 600,
        width: 450,
        overlay: {
            opacity: 0.7,
            background: "black"
        },
        draggable: true,
        resizeable: true,
        open: function() {
            //display correct dialog content
            $("#dialogDiv").load(url);
        }
    };

    $("#dialogDiv").dialog(dialogOpts); //end dialog
    $("#dialogDiv").dialog("open");

});

});

Here is my controller action code:

    public ActionResult Info(int id)
    {
        return PartialView("LabelPartialView", _Repository.GetItem(id));            
    }

Here is the issue:

When i click this the first time (lets say i send id = 1234) it works fine.
When i click on another item (lets say i send id = 4567) it shows the content from 1234 still.
Which i click this second item again (again its 4567), then it will show the content from 4567.

Does anyone know why it might not be refreshed the first time? Is this a timing issue?

© Stack Overflow or respective owner

Related posts about asp.net-mvc

Related posts about jquery-ui-dialog