Wednesday, June 17, 2009

Ruby on Rails functions to call function remotly(Ajax) or directly

#Remote Function Call
remote_function( :url => {:action => 'close_div'}, :with => "'div_id="+@div_id+"'") %>

# button_to_function
button_to_function "Greeting", "alert('Hello world!')"
button_to_function "Close", remote_function(:url => {:action => 'close_div'}, :with => "'div_id="+@div_id+"'")

# link_to_function
link_to_function "Greeting", "alert('Hello world!')"

# link_to_remote
link_to_remote "Delete this post", :update => "posts", :url => { :action => "destroy", :id => post.id }

No comments:

Post a Comment