Is it possible to use the rails syntax inside of application.js file. Basically, I want to use remote_function call inside of a javascript function. I know I could use the Ajax.Request but then I have a problem with an authenticity token. I''ve tried this: function callRemote(){ <%= remote_function(:url => {:action => :my_function}) %> } And this syntax does not fly in the application.js. So is it possible to use the rails syntax in some way in application.js file? -- 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 -~----------~----~----~----~------~----~------~--~---
No. This is just a javascript file, you cannot use Rails syntax in it. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Greg Lazarev wrote:> Is it possible to use the rails syntax inside of application.js file. > Basically, I want to use remote_function call inside of a javascript > function. > I know I could use the Ajax.Request but then I have a problem with an > authenticity token. > > I''ve tried this: > function callRemote(){ > <%= remote_function(:url => {:action => :my_function}) %> > } > And this syntax does not fly in the application.js. > So is it possible to use the rails syntax in some way in application.js > file?ruby script/generate controller Javascripts add "map.connect ''javascripts/:action.js''" to config/routes.rb create app/views/javascripts/app.erb add the line "caches_page :app" to app/controllers/javascripts_controller.rb in your template add "javascript_include_tag(:app)" --- now you have app.js dynamically generated from erb and cached. -- 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 -~----------~----~----~----~------~----~------~--~---