1

I'll start out saying that this works perfectly in Chrome and Firefox but not IE (IE9).

Desired behavior: I have a Partial View on my page that contains a hyperlink. When you click on the hyperlink it uses a jQuery function to pop up a dialog to enter a new note. When you close the dialog, it should refresh the Partial View with the new count.

In IE, it works on the first pass, but not subsequent.

I'm using jQuery 1.6.1 and jQuery UI 1.8.13 for the dialog.

Here is my function that is getting called by the hyperlink, and I have confirmed that it is hitting this function every time, just not making it to the controller when .load is called (or it's losing sight of the close function):

function showNoteDialog(id) {
    //alert(id);
    var dialogOpts = {
        title: 'Add Note',
        modal: true,
        autoOpen: false,
        height: 600,
        width: 600,
        closeOnEscape: true,            
        open: function (event, ui) {
            jQuery.ajaxSetup({ cache: false });
            //display correct dialog content
            $('#noteDialog).load('<%= Url.Action("ModalNoteEdit","Notes")%>', { id: id });
        }
        ,
        // refresh the partial view
        close: function (event, ui) {
            $('#noteList).load('<%= Url.Action("NoteList","Notes")%>');                
        }
    };
    $('#noteDialog).dialog(dialogOpts);
    $('#noteDialog).dialog('open');

    //end dialog
    return false;
}
BenMorel
  • 34,448
  • 50
  • 182
  • 322
Papa Burgundy
  • 6,397
  • 6
  • 42
  • 48

2 Answers2

5

I'm betting that IE is caching the result of the ModalNoteEdit action. I'd try doing something to prevent that caching. Maybe setting a response header, or adding a querystring to that request that changes every time. For instance:

$('#noteDialog).load('<%= Url.Action("ModalNoteEdit","Notes")%>' + Date.now(), { id: id });
FlyingDeveloper
  • 342
  • 2
  • 10
  • 1
    +1. Also see http://stackoverflow.com/questions/168963/stop-jquery-load-response-from-being-cached – StriplingWarrior Jun 09 '11 at 17:43
  • this sounds like it could be the issue though. because sometimes when I add a new row and the dialog does work, it will still bring back old data. I had a similar problem with the dialog being cahced and you can see above that I placed jQuery.ajaxSetup({ cache: false }); in the open function. I'll place it in the close later and let you know. Thanks. – Papa Burgundy Jun 09 '11 at 18:04
  • 4
    It was a CACHE issue. I added jQuery.ajaxSetup({ cache: false }); in the close function and it works fine. – Papa Burgundy Jun 09 '11 at 23:08
  • 1
    This was killing me too. It was when users had IE to check for new version of the page 'automatically' rather than 'every time I visit the page'. jQuery.ajaxSetup(...) solved it – Richard Mar 17 '13 at 20:31
1

You're missing a lot of closing simple quotes in your selectors.

$('#noteDialog) should be $('#noteDialog'), etc.

Bertrand Marron
  • 21,501
  • 8
  • 58
  • 94