I''m trying to work with AJAX on Rails 3 but I cant find any documentation or a guide for learning it, is there a good one out there to start practicing? -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
forget ujs ,only use jquery that is very easy and also work fine. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Tue, May 24, 2011 at 8:58 AM, Tomas R. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> I''m trying to work with AJAX on Rails 3 but I cant find any > documentation or a guide for learning it, is there a good one out there > to start practicing? > >just add a .js.haml (or erb) template and add the js response to that file. for example, you''re sending an ajax request to the create action of posts controller. just add a create.js.haml file and add the script you want in that 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- ------------------------------------------------------------- visit my blog at http://jimlabs.heroku.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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Tue, May 24, 2011 at 2:58 AM, Tomas R. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: I''m trying to work with AJAX on Rails 3 but I cant find any> documentation or a guide for learning it, is there a good one out there > to start practicing? >There has been a couple of attempts at writing an Ajax guide, but none finished (and none ongoing as of this writing that I am aware of). An Ajax guide would be very helpful if anyone wants to volunteer one :). -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
bill gate wrote in post #1000518:> forget ujs ,only use jquery > that is very easy and also work fine.@Tomas, ignore this reply Unobtrusive JavaScript (UJS) and jQuery are completely unrelated. One has nothing to do with the other. jQuery can be just as obtrusive, or unobtrusive, as any JavaScript. I do agree, however, it would be nice to have an "official" guide to JavaScript (& CoffeeScript). -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I also don''t know of any good guides for this.  You can see the
relevant RailsCast for it:
http://railscasts.com/episodes/205-unobtrusive-javascript
where Ryan Bates discusses using the *.js.erb style of returning JS to
the page to be executed.
I''d recommend reading through the rails adapter you''re using. 
It will
help to give you some idea of how it works.  If using JQuery, you can
hook into a series of triggered events throughout the AJAX call
lifecycle. Here''s an example to handle the response from a AJAX-y
link:
$(''a[data-remote]'').live(''ajax:complete'',
function(xhr, response) {
      if (response.status == 200) {
        $(''#resource-display'').html(response.responseText);
      } else {
        $(''#resource-display'').html(''Error loading
content'');
      }
    });
Fundamentally, though, there *does* need to be better documentation
about this.  It''s certainly one of those ''someone needs to do
it''
moments, and we can''t really blame anyone else but ourselves!
Casey
On May 24, 7:25 am, Robert Walker
<li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>
wrote:> bill gate wrote in post #1000518:
>
> > forget ujs ,only use jquery
> > that is very easy and also work fine.
>
> @Tomas, ignore this reply Unobtrusive JavaScript (UJS) and jQuery are
> completely unrelated. One has nothing to do with the other. jQuery can
> be just as obtrusive, or unobtrusive, as any JavaScript.
>
> I do agree, however, it would be nice to have an "official" guide
to
> JavaScript (& CoffeeScript).
>
> --
> Posted viahttp://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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
so before trying ajax i need to learn javascript right? -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Yes, absolutely. AJAX stands for "Asynchronous Javascript". So learning some Javascript is key. On May 24, 12:53 pm, "Tomas R." <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> so before trying ajax i need to learn javascript right? > > -- > Posted viahttp://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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.