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.
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();
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With