Invoke a controller def from view without clicking any link


#1

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


#2

On May 11, 8:01 am, Sijo Kg removed_email_address@domain.invalid 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


#3

Hi
In my partial I tried like

But this onload not working Since I tried with an alert first Could
you please tell how can I do this?

Sijo


#4

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.