Hi All, Does anyone know if there are any good examples of how to use the unobtrusive javascript functionality in Rails 3. I''ve read the release notes but I can''t seem to get things working. I''ve just set up a simple Rails app with a Post model. In the "_form" partial I have add the ":remote => true" parameter, as required. When I submit the form it saves the record asynchronously, as expected but it doesn''t redirect to the appropriated page afterwards. Any ideas what I''m doing wrong? Thanks! Phil -- 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.
Useful link I found:- http://joshhuckabee.com/jquery-rails-3 On Feb 8, 9:56 am, overture <phil.mccl...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi All, > > Does anyone know if there are any good examples of how to use the > unobtrusive javascript functionality in Rails 3. I''ve read the > release notes but I can''t seem to get things working. > > I''ve just set up a simple Rails app with a Post model. In the "_form" > partial I have add the ":remote => true" parameter, as required. When > I submit the form it saves the record asynchronously, as expected but > it doesn''t redirect to the appropriated page afterwards. > > Any ideas what I''m doing wrong? > > Thanks! > Phil-- 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.
On Tue, Feb 9, 2010 at 10:35 AM, overture <phil.mcclure-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Useful link I found:- > > http://joshhuckabee.com/jquery-rails-3Does the HTML5 stuff in Rails3 degrade to something else for browsers that don''t support it yet? I''ve read all the Rails3 news I can find but don''t see this answered anywhere. -- Greg Donald destiney.com | gregdonald.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 don''t think that Rails 3 is using anything that wouldn''t already be supported by older browsers. It''s not like it''s sticking in <canvas> by default, just using some special named parameters. A large goal with HTML5 was backward compatibility. -- 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.
Maybe there will be some good examples available soon. Hope so. -- 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 just did a post on using UJS in Rails 3 - http://therailworld.com/posts/26-Using-Prototype-and-JQuery-with-Rails3-UJS- On Feb 9, 8:40 pm, overture <phil.mccl...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Maybe there will be some good examples available soon. Hope so.-- 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.
On Thu, Feb 11, 2010 at 3:33 PM, overture <phil.mcclure-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I just did a post on using UJS in Rails 3 - > http://therailworld.com/posts/26-Using-Prototype-and-JQuery-with-Rails3-UJS-<snip> so if you wanted to use JQuery or MooTools you would need to do make your own solution. </snip> Wrong. There is JRails which uses jQuery and provides all same javascript helpers. http://github.com/aaronchi/jrails In addition, any jQuery you want to run through the page object is as simple as: page << "$(''#foo'').bar();" -- Greg Donald destiney.com | gregdonald.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.
JRails is just a drop in replacement for PrototypeHelper in Rails releases prior to 3. Rails 3 looks is phasing out PrototypeHelper in favour of UJS. The goal of UJS is to eliminate all inline Javascript. The end result of this is that all your favourite javascript generating helpers will be deprecated. link_to_remote, form_remote_for, link_to_function, and the rest will be gone. Yes. a driver file will need to be created for each of mootools, jquery or any other javascript frame work to use the new :remote => true syntax of Rails 3. But they''re pretty simple files that don''t change too much from the prototype example that ships with rails ("rails.js"). You can use the new prototype_legacy_helper or a slightly modified JRails with Rails 3 to restore the old way of doing Javascript in Rails. But it wouldn''t be the Rails 3 way of doing things. By the time Rails 3 gets a proper release there will be drivers for all the popular Javascript frameworks. On Feb 11, 7:51 pm, Greg Donald <gdon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Thu, Feb 11, 2010 at3:33 PM, overture <phil.mccl...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > I just did a post on using UJS inRails3- > >http://therailworld.com/posts/26-Using-Prototype-and-JQuery-with-Rail... > > <snip> > so if you wanted to use JQuery or MooTools you would need to do make > your own solution. > </snip> > > Wrong. There is JRails which uses jQuery and provides all same > javascript helpers. > > http://github.com/aaronchi/jrails > > In addition, any jQuery you want to run through the page object is as simple as: > > page << "$(''#foo'').bar();" > > -- > Greg Donald > destiney.com | gregdonald.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.
I''m going to retract a part of my response, particularly the bit stating that plugins/gems like JRails are unnecessary in Rails 3. After doing a little more digging on the issue, it looks like JRails will still be required if you''re looking to use RJS templates to generate JQuery. This goes for other JS frameworks like Mootools or Dojo as well -- 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.
The underlying meaning of this statement is; Rails as a framework use to favour a certain Javascript framework (Prototype). This doesn''t mean that you alone would need to write your own solution for JQuery, but someone, somewhere *did* have to write JRails. Likewise, if you wanted to use Mootools, someone would need to write a solution for it. Rails 3 and UJS solve this problem, among others. On Feb 11, 7:51 pm, Greg Donald <gdon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Thu, Feb 11, 2010 at 3:33 PM, overture <phil.mccl...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > I just did a post on using UJS in Rails 3 - > >http://therailworld.com/posts/26-Using-Prototype-and-JQuery-with-Rail... > > <snip> > so if you wanted to use JQuery or MooTools you would need to do make > your own solution. > </snip> > > Wrong. There is JRails which uses jQuery and provides all same > javascript helpers. > > http://github.com/aaronchi/jrails > > In addition, any jQuery you want to run through the page object is as simple as: > > page << "$(''#foo'').bar();" > > -- > Greg Donald > destiney.com | gregdonald.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.
Greg Donald wrote:> Wrong. There is JRails which uses jQuery and provides all same > javascript helpers. > > http://github.com/aaronchi/jrailsJRails is obtrusive javascript, where rails 3 implements unobtrusive javascript. Using JRails along with Rails 3 just seems...wrong. I always thought using JRails in itself was kind of wrong, just because JQuery focuses more on unobtrusive javascript. This was the reason I started using JQuery in the first place. I think the correct solution is to look at the new Implementation of the unobtrusive prototype helpers in Rails 3, and write similar unobtrusive JQuery, using JRails to help. -- 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.