File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes Value in the textarea is not retaining in jquery popup modal. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Value in the textarea is not retaining in jquery popup modal." Watch "Value in the textarea is not retaining in jquery popup modal." New topic
Author

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

Paranidharan Selvaraj
Greenhorn

Joined: Mar 19, 2010
Posts: 17
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

Joined: Jan 10, 2002
Posts: 61761
    
  67

Where and how are you executing the code to re-populate the value. The textarea must exist before trying to fill it in.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Paranidharan Selvaraj
Greenhorn

Joined: Mar 19, 2010
Posts: 17
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;
}
}
});

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Value in the textarea is not retaining in jquery popup modal.