javascript - UJS partial rendering in Rails 3 -


I am struggling to get my head about how to implement UJS of Rail (in particular, Rail 3 with jQuery) I

What I did while submitting the form through AJX, and what can I do after this, but to expand this concept, let me add a javascript function to the html element in my view files Having trouble connecting . After all, I would like to be able to create a form where a different partial is provided, depending on which radio button is selected from a series. Am I looking for prototype heritage helpers? And why do I need to create a .js.erb file?

Sorry for the newbie question, I can not find the concept of UJs very clearly and how to use it in the rail. Switch from code to AJC / RJS approach Any lot of help Will be appreciated!

remote => The correct on the form , your data will go to the server and all returned javascript will be executed in the context of the page, so this is a simple example:

  & lt; % = Form_tag '/ action_path',: remote = & gt; True is% & gt; & Lt;% = radio_button_tag 'partial', 'one'% & gt; & Lt;% = radio_button_tag 'partial', 'two'% & gt; Select & lt;% = submit_tag '%' & Lt;% end% & gt; & Lt; Div id = "partial_holder" & gt; & Lt; / Div & gt;  

On the server

  def action #do Whatever you want with the parameter end  

action.js On .erb file

  $ ('# partial_holder'). Html ("and lt;% = escape_javascript (render (: partial = & gt; parameter [: partial]))% & gt;")  

Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -