Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Value in the textarea is not retaining in jquery popup modal.

 
Paranidharan Selvaraj
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a popup modal dialogue... The user will be asked to enter the text inside the textarea of the popup. I have edit,save and close buttons.. User clicks edit and changes the text inside the textarea and opts to close without saving. When the user opens the popup again the value in the popup textarea is not retaining. I am using jquery to do this.

'Close': function() {
$('input[type="text"], textarea').attr('readonly','');
$(this).dialog('close');
}


I have tried setting the value again the textarea like
$(this).val("original text"); not succeeding though.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64632
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where and how are you executing the code to re-populate the value. The textarea must exist before trying to fill it in.
 
Paranidharan Selvaraj
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry for the delayed reply.. I have a textarea inside a div tag in jsp. On click of an image i use jquery modal dialogue to open the popup.

Jsp Code:

<div id='popup0' class="ui-widget-content ui-corner-all" title="Confidential Comments" style="display:none" >
<textarea name="accounts[0].justificationComments" style="width:480px ;height:150px;border:0px;">test </textarea>
</div>

My problem is i get the textarea in the popup. I am able to save/edit/close the modal window. One bug that is repeatedly bothering me is when i click on edit i am able to edit the content inside but without saving if i click the button close the value is retaining when i open the popup again. It should only happen if is use save button.

buttons: {

'Cancel': function() {
document.getElementById(imageDiv).style.display="none";
document.getElementById(checkboxId).checked=false;
document.getElementById(hiddenId).value= "";
$('input[type="text"], textarea').attr('readonly','');
$(this).dialog('close');
},
'Close': function() {
$('input[type="text"], textarea').attr('readonly','');
$(this).dialog('close');
},
'Save': function() {
var text = $(this).text();
document.getElementById(hiddenId).value= text;
$(":button:contains('Edit')").attr("disabled","");
$(this).dialog('close');
},
'Edit': function() {
$('input[type="text"], textarea').attr('readonly','');
$(":button:contains('Save')").show();
$(":button:contains('Edit')").attr("disabled","disabled");
return;
}
}
});

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic