Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

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

 
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.
 
Marshal
Posts: 67418
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • 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;
}
}
});

 
She said she got a brazillian. I think owning people is wrong. That is how I learned ... tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic