If I have (inline RJS for simplicity) can I do this?
render :update do |page|
new Ajax.Request(’<%= url_for(:action => “/test/foo”, :what =>
“ever”)
%>’, {asynchronous:true, evalScripts:true});
end
Ajax.Request will trigger a controller action - you simply need to
decide when to call it - either as inline code in which case it will be
executed when the page is rendered, or in response to some event, eg
onClick=‘new Ajax.Request…’
If I have (inline RJS for simplicity) can I do this?
render :update do |page|
new Ajax.Request(’<%= url_for(:action => “/test/foo”, :what =>
“ever”)
%>’, {asynchronous:true, evalScripts:true});
end
Ajax.Request will trigger a controller action - you simply need to
decide when to call it - either as inline code in which case it will be
executed when the page is rendered, or in response to some event, eg
onClick=‘new Ajax.Request…’
Yes, I understand that, as I usually use it in partials for executing
controller functions.
My question is though how to call it from within a RJS template or
within inline RJS code?
What would the syntax be?
Is it possible at all or do I have to render a partial to be able to use
the Ajax.request call??
In fact you just need to use the
[url=http://api.rubyonrails.com/classes/ActionView/Helpers/PrototypeHelper.html#M000420]remote_function
helper. If you omit the :update parameter, it generates an Ajax:Request
call instead of AjaxUpdater - eg: