Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cannot clear previous text on jquery modal popup

I'm trying to clear the previous text on the modal popup but I cannot do that I have searched internet but couldn't found any appropriate solution to my problem, I'm sharing my code please guide me

JQUERY:

$('table').on('click', function(e){
    e.preventDefault();
    var clone = $(this).clone();
    $( "#popup" ).dialog({
        open: function( event, ui ) {
            $(this).html(clone);
        },
        buttons: {
            "Okay": function () {

                $(this).dialog("close");

            },           
        },        
    }); 
    $("#sumresult").clone(true).appendTo("div.ui-dialog-buttonpane").show();
});

HTML:

<table>
  <tr>
   <th>Part</th>
   <th>ID</th>
  </tr>
  <tr>
    <td>New part</td>
    <td>231134</td>
  </tr>
  <tr>
    <td>New part</td>
    <td>231134</td>
  </tr>
</table>

<div id="popup" title="Table Preview"></div>
<div id="sumresult">12390.21</div>

FIDDLE: http://jsfiddle.net/hg9NJ/3/

when I open modal again and again it will show the same value multiple times as I open.

like image 871
DevWithSigns Avatar asked Jan 25 '26 09:01

DevWithSigns


1 Answers

Just clear the html of the popup

FIDDLE DEMO

$('table').on('click', function(e){
     $(".ui-widget-content").html(""); // clear html 
    e.preventDefault();
    var clone = $(this).clone();
    $( "#popup" ).dialog({
        open: function( event, ui ) {


            $(this).html(clone);
        },
        buttons: {
            "Okay": function () {

                $(this).dialog("close");

            },           
        },        
    }); 
    $("#sumresult").clone(true).appendTo("div.ui-dialog-buttonpane").show();
});
like image 102
Mark Avatar answered Jan 27 '26 22:01

Mark