Hi I have a controller def like def graph_render get_flash_chat_objects respond_to do |format| format.js do render :update do |page| page[:graph_div].replace_html :partial => "summary_graph" end end end end So clearly this just accept an ajax request and do the above action This is working But what I would like to know how can I invoke it from view without clicking a link or like that Thanks in advance Sijo -- Posted via http://www.ruby-forum.com/.
Frederick Cheung
2009-May-11 08:41 UTC
Re: invoke a controller def from view without clicking any link
On May 11, 8:01 am, Sijo Kg <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > So clearly this just accept an ajax request and do the above action > This is working But what I would like to know how can I invoke it from > view without clicking a link or like that >Well unless you have a javascript timer on the page that fires off your ajax request, it''s going to have to happen in response to some event (not necessarily a mouse click, could be page load, mouseover, keydown etc...) Fred> Thanks in advance > Sijo > -- > Posted viahttp://www.ruby-forum.com/.
Sijo Kg
2009-May-11 08:50 UTC
Re: invoke a controller def from view without clicking any l
Hi In my partial I tried like <div id"graph_div" onload="somescript();"> </div> But this onload not working Since I tried with an alert first Could you please tell how can I do this? Sijo -- Posted via http://www.ruby-forum.com/.
Use prototype functions to handle the onload events. It is better than plugging in onload code into your HTML tags. Look at the online documentation for examples. You can use either the dom:loaded event or the window:onload event. On May 11, 1:50 pm, Sijo Kg <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Hi > In my partial I tried like > <div id"graph_div" onload="somescript();"> > </div> > > But this onload not working Since I tried with an alert first Could > you please tell how can I do this? > > Sijo > -- > Posted viahttp://www.ruby-forum.com/.