Sarika Rajput
Sarika Rajput

Reputation: 83

Jquery dialogbox content sometimes returns old data

so on my page i'm having many button each button contains some data and when I click on any button it opens dialog box with 2 input both date type..and if i change something it will save it for that particular button. The problem is if i click on button A sometimes(very rarely this happen but still i need to find some solution) the dialog opens data for button C.What to do..?

Any suggestion or help appreciated.

Thanks.

Code:

            $("#dialog").dialog({

                            height: 450,
                            width: 450,
                            modal: true,
                            title: "Dialog BOx",

                            buttons: {

                                "Save": function () {
                                   start_dt = moment($('#start_txt').val());
                                   end_dt = moment($('#end_txt').val());
                                   _this.SaveData(start_dt,end_dt);
                                   $(this).dialog('close');
                              }
                                close: function () {
                                   $(this).dialog('close');
                            },

                        });

HTML:

              <div id="dialog" title="" style="width:500px;">
               <input type="date" id="start_txt"/>
               <input type="date" id="end_txt"/>  
                </div>

Upvotes: 0

Views: 68

Answers (1)

CandleCoder
CandleCoder

Reputation: 1503

Use Dialog Close event with

$("#dialog")
   .dialog({
     closeOnEscape: true,
     show: "slow",
     model: true,
     minWidth: 600,
     close: function( event, ui ) {
           //Do stuff on close
           //Now call "destroy"
          $("#dialog").dialog("destroy");
     }
  });

Upvotes: 1

Related Questions