# New window parameters disappear with validation fails

**URL:** <https://www.ruby-forum.com/t/new-window-parameters-disappear-with-validation-fails/184447>\
**Category:** Rails\
**Created:** [March 2, 2010, 5:44pm UTC](https://www.ruby-forum.com/t/new-window-parameters-disappear-with-validation-fails/184447 "2010-03-02T17:44:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jmaenpaa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9de053/32.png) [@jmaenpaa](https://www.ruby-forum.com/u/jmaenpaa)\
**Post date:** [March 2, 2010, 5:44pm UTC](https://www.ruby-forum.com/t/new-window-parameters-disappear-with-validation-fails/184447/1 "2010-03-02T17:44:26Z")

</div>

Hello all,  
My 5th month with Ruby on Rails is over and on to #6, but still  
learning.

I have an application…  
Rails 2.3.5  
Ruby 1.8.7

I have a jQuery dialog box that gives the user the option to “create” a  
new project or “Cancel”.  
When “Create New” is clicked, a new browser window is opened with the  
“new” view display.  
Everything works fine until I add validation to the form.  
If a validation error occurs, the id that I passed disappears and the  
data is lost.

Here’s the function call for the jQuery dialog box.

function createNewProject(irb\_id){  
jQuery.ui.dialog.defaults.bgiframe = true;  
jQuery(function(){  
jQuery(’#confirmDialog’).dialog({  
title: ‘Create New Project’,  
width: 225,  
hide:{effect: ‘blind’, duration: 500},  
resizable:false,  
buttons:  
{  
‘Cancel’: function(){  
jQuery(this).dialog(‘close’).dialog(‘destroy’);  
window.location.reload(true);  
},  
‘Create New Project’: function(){  
jQuery(this).dialog(‘destroy’);  
jQuery.ajax({  
type:‘GET’,  
success: function(){  
//redirect\_to\_newProject(irb\_id);  
jQuery(this).dialog(‘close’).dialog(‘destroy’);  
removeRow(id);  
removeProjectResults(id);  
// open new browser window  
window.open(’/projectdb/projects/new?id=’+irb\_id,  
‘New Project’,  
‘left=20, top=20, width=1100, height=700, toolbar=0,  
resizable=1, scrollbars=1’);  
},  
error: function(){  
alert(‘error’);  
}  
}); //end ajax call  
} // end of Confirm Link button  
} // end buttons  
}); // end jQuery dialog  
}); // end jQuery function  
}

I’m not sure what happens, but if I reload the window after the error  
occurs, the data reappears.

Thank you for any help on this.

JohnM

---

<div class="post-metadata">

**Author:** ![jmaenpaa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9de053/32.png) [@jmaenpaa](https://www.ruby-forum.com/u/jmaenpaa)\
**Post date:** [March 3, 2010, 10:22pm UTC](https://www.ruby-forum.com/t/new-window-parameters-disappear-with-validation-fails/184447/2 "2010-03-03T22:22:06Z")

</div>

When you’re “new” action fails, it moves to the “create” function  
which simply renders the “new” view; it doesn’t call the “new” action  
again…

So you’re loosing an ID? Is it part of the object your passing  
through? It might be worth creating a hidden field to place the ID in
