<%% if @<%= instance_name %>.errors.blank? %> // Fill the right box with first item details $('#div_<%= instance_name %>_details').html("<%%= escape_javascript(render(:partial=>"show")) %>"); // Refresh the updated item in the list $("#div_<%= instance_name %>_<%%= @<%= instance_name %>.id %>").html("<%%= escape_javascript(render :partial => 'item', :locals => { :<%= instance_name %> => @<%= instance_name %> }) %>") // Close Modal closeModal(); <%% else %> // Reload the form partial to display errors $('#div_<%= instance_name %>_details').html("<%%= escape_javascript(render(:partial=>"edit")) %>"); // Validate the form validate<%= model_class %>Form(); // Populate Server Side Errors errorMessages = <%%= @<%= instance_name %>.errors.full_messages.to_json.html_safe %>; populateServerSideErrors('<%= instance_name %>', errorMessages); <%% end %>