-1

I am stuck with this issue for the past 4 hours. I m displaying a partial view in a jquery modal dialog. Everything works fine until I noticed that when I load the dialog the first time it does a post to the controller for the action specified but all subsequent clicks to open the dialog does not do any post at all.

I have a link button clicking on which should open the dialog, the first time I see it does a post the next time no post happens at all. Kindly look at my code and please suggest a solution. I have tried most of the solutions provided but none of them work. Here is the code.

 $(document).ready(function () {

 //Modal window for Payment Summary
        $('.button-link').on('click', function () {

            //$('body').find("#paymentSummaryForm").remove();                           
            $("#paymentSummaryForm").dialog({
                dialogClass: 'no-titlebar',
                autoOpen: true,
                position: { my: "center", at: "top+410", of: window },
                width: 1000,
                height: 750,
                resizable: false,
                draggable:true,
                //title: 'Payment Summary',
                modal: true,
                open: function (event, ui) {
                    $(this).load('@Url.Action("PaymentSummaryView", "Home", new {id= @DateTime.Now.ToShortTimeString() })');
                },
                buttons: {
                    Close: function () {                            
                        $(this).dialog("close");
                    }
                }
            });
            return false;
        });

This is the code which triggers the dialog

<tbody>
    <tr>
       <td>
 <button type="button" class="button-link"> 
             @Model.AcctNumber
  </button></td>
                </tr>
            </tbody>
        </table>

I have tried the destroy, empty and lot of other options..none of them seem to work. Please help me.

NewTech
  • 316
  • 5
  • 23
  • `Uncaught TypeError: $(...).dialog is not a function` I'm trying to reproduce your code. Can I see the dialog box html? Its not clear at all to me what you are trying to do. In simple english can you define what's supposed to be happening here? Think user story.. It starts `A user clicks on the "Model Account" button` and then,... – zipzit May 11 '16 at 19:12
  • Sure..here is the use case....................................1. User logs into the website and clicks on a account number in a grid which is basically a link. 2. clicking on that link will open up the dialog with more information of the account 3. User logs off and suppose another user logs in with a different id, the modal dialog shows the information from the first user. The first time the post happens on the action method for the partial view but the second time the post does not happen and it loads the same previous dialog. its a Jquery-ui dialog – NewTech May 11 '16 at 19:31
  • The load function is only loading the first time...does that help you get a clear picture ? – NewTech May 11 '16 at 19:32

1 Answers1

1

IE aggressively caches jquery gets. I've run into this before.

See this question.

How to prevent a jQuery Ajax request from caching in Internet Explorer?

you may want to add a guid query string to make the url unique. That way ie won't cache it.

Community
  • 1
  • 1
Fran
  • 6,440
  • 1
  • 23
  • 35
  • if you see the code I do have a timestamp added to the url to make it unique even that wont help..... ('@Url.Action("PaymentSummaryView", "Home", new {id= @DateTime.Now.ToShortTimeString() })' – NewTech May 11 '16 at 19:34
  • did you try turning off all ajax caching with the ajaxSetup object? – Fran May 11 '16 at 19:36
  • how can I do that ? I m not sure what you mean..Could you please explain ? – NewTech May 11 '16 at 19:59
  • 1
    That link from Fran is pretty good. Just add `$.ajaxSetup({ cache: false });` to your javascript script somewhere, anywhere... – zipzit May 11 '16 at 20:04
  • but will that call help in my case ? I m not using a direct ajax call not sure if I make sense but if you look at my code above will this work with that ? I m going to try it any way – NewTech May 12 '16 at 12:27
  • 1
    Load() is an Ajax call. – Fran May 12 '16 at 12:39
  • @Fran thank you so much for your answer..that helped me solve the issue. +1 for suggesting – NewTech May 12 '16 at 12:44