html rendering is done this way : ( sorry… haml code…)
= form_for(resource, :as => resource_name, :url =>
user_registration_path(I18n.locale) ) do |f|
= render “shared/error_messages”, :target => [resource]
and the shared/error_messages partial is quite standard ( made
visible or not… if no errors…)
#resource_error_messages{:style => “display:#{errorsInForms(target) >
0 ? ‘visible’ : ‘none’}”}
#error_explanation
- target.each do |field|
- if field.errors.any?
%ul
- field.errors.full_messages.each do |msg|
%li= msg.html_safe unless msg.nil?
this runs very well … but I need to output it with a js request
( render :action => ‘create.js’ )
in my create.js.erb , I wrote :
$(’#resource_error_explanation’).html("<%= escape_javascript( render
‘shared/error_messages’, :target => [resource] ) -%>");
to render the errors, then I show the div
$(’#resource_error_messages’).show();
but the errors are NOT rendered at all… what should I write
instead ??
thanks for your feedback