Hello, I currently have in my ''view/rhtml page'' a link_to, as follows: <% link_to_remote "run", :before => "new Effect.Shake(''myform'')", :url => {:action => ''execute'', :id => @input } %> This calls a method ''execute'' in my controller. ''execute'' runs a loop. OK, i would like to be able to update the rhtml page from within this method in my controller. How do i do this? For exmaple, the loop would just alter a variable and update a div in the web page. -- 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 -~----------~----~----~----~------~----~------~--~---
James Smith wrote:> Hello, > > I currently have in my ''view/rhtml page'' a link_to, as follows: > > <% link_to_remote "run", :before => "new Effect.Shake(''myform'')", :url > => {:action => ''execute'', :id => @input } %> > > This calls a method ''execute'' in my controller. ''execute'' runs a loop. > OK, i would like to be able to update the rhtml page from within this > method in my controller. How do i do this? > > For exmaple, the loop would just alter a variable and update a div in > the web page.You can use RJS. controller: def execute #process form here @new_value = set to the variable value you mentioned end in the view execute.rjs: page.replace_html ''div_name'', ''your html code here'' page << "$(''your_variable'').value = #{@new_value}" -- 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 -~----------~----~----~----~------~----~------~--~---
> You can use RJS. > > controller: > > def execute > #process form here > @new_value = set to the variable value you mentioned > end > > in the view execute.rjs: > > page.replace_html ''div_name'', ''your html code here'' > page << "$(''your_variable'').value = #{@new_value}"Thanks for your comments, they were very helpful. Although, I think the code in the rjs file is executed as sson as the corresponding method in the controller is called, right? I would like to be able to loop in the controller, and if some condition is true - then execute the javascript and update the page. Going into my problem more specifically, what i am doing is trying to get input from the user. So, when the user clicks the button on the webpage i would, method ''execute'' is called in the controller, which runs a loop. When some condition in this loop is true, i then want to execute some javascript, which will toggle a textfield into view (or display a prompt), allow the user to input a string, and when confirmed (OK clicked), feed ths string back into a variable in my loop. Do you think this would be possible? Thanks again. -- 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 -~----------~----~----~----~------~----~------~--~---