Hello, 7stud thanks for that :) Looks like a lot of GOOD info. I will give it a go and revert :)
On 7 September 2011 01:52, 7stud -- <li...@ruby-forum.com> wrote: > 1) I do this: > > <%= > javascript_include_tag( > "http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js", > "jquery.rails.js" > ) > %> > > No gem needed. You can read here about the advantages of using a google > link: > > http://encosia.com/3-reasons-why-you-should-let-google-host-jquery-for-you/ > > Note that railscast #205 Unobtrusive Javascript also uses a google link > rather than a gem. > > > 2) Following railscast #205 Unobtrusive Javascript, I put this file: > > https://github.com/rails/jquery-ujs/tree/master/src > > in the same directory as the default rails.js file, and I named it > jquery.rails.js. Note how in 1) I link to jquery.rails.js. That way > you don't need to delete the prototype file. > > > 3) In rails 3, you use respond_to/respond_with > > > class SomeController < Application Controller > > respond_to :html, :xml, :js > > def some_action > respond_with(@user) > end > > > See here: > > > http://stackoverflow.com/questions/3876891/how-do-i-specify-layout-false-in-rails-respond-with > > > 4 & 5) It's my understanding that having data-remote="true" in an html > element causes an ajax request to be sent to the specified action. > After the action executes, the *default* is for rails to render a page > called action_name.js.erb, which sends the js on the page back to the > browser, and then the browser executes the js. However, you told rails > not to preform the default: > > render :json => {:name => 'John'} > > So rails sends that text back to the browser--rather than the js in > action_name.js.erb. I can think of two solutions: > > 1) json is the same format as a js object. So you can just put your > json in your js in action_name.js.erb > > 2) You can write this in your controller: > > @name = "John" > > and then use @name in action_name.js.erb. > > In other words, you are currently wanting to send two responses in > response to one ajax request: the json and the js in some_action.js.erb. > Rails is sending back one response. > > -- > 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@googlegroups.com. > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > > -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.