What i''m trying to get working is I have a controller called "permissions" and a view "permissions.rhtml". This view has a hidden div that contains a form for adding new roles. Its just a single textfield. Also on the page I have a dropdown list of roles and then underneath that a div that contains a list of permissions for the role selected in the dropdown. I have a link that when clicked makes the hidden form div visible. What I would like is for the form to submit via AJAX to a new_role controller method. Any errors would be highlighted in my "error_messages_for ''role''" call at the top of the permissions.rhtml file. When it has submitted correctly the dropdown list would be updated with the new selection. What I have got so far is that the page wants to show a "new_form" page? -- Posted via http://www.ruby-forum.com/.
James Whittaker wrote:> What i''m trying to get working is I have a controller called > "permissions" and a view "permissions.rhtml". This view has a hidden div > that contains a form for adding new roles. Its just a single textfield. > Also on the page I have a dropdown list of roles and then underneath > that a div that contains a list of permissions for the role selected in > the dropdown. I have a link that when clicked makes the hidden form div > visible. > > What I would like is for the form to submit via AJAX to a new_role > controller method. Any errors would be highlighted in my > "error_messages_for ''role''" call at the top of the permissions.rhtml > file. When it has submitted correctly the dropdown list would be updated > with the new selection. > > What I have got so far is that the page wants to show a "new_form" page?Ok I will rephrase it: How can I get Error messages to show when using ajax form submit? -- Posted via http://www.ruby-forum.com/.
James > How can I get Error messages to show when using ajax form submit? In the controller''s response to the submit, you will send an html fragment with RJS code like: ... page.replace_html "the_div_id", :partial => ''some_html_fragment'' ... The trick is for the html fragment to include the error displaying Rails code : ... <%= error_messages_for ''foo'' %> .... Alain
or you could do something like this without having to use a partial render :update do |page| page.replace_html ''address_errors'', :inline=>"<%= error_messages_for :address %>" end -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Apparently Analagous Threads
- Validation error messages help please
- Problems Processing multiple form elements generated by javascript actions
- error_messages_for when saving within another model
- undefined method `with_indifferent_access' for "":String
- How to Pass Jquery selected dropdown values and radio button values to controller