Greetings all, I think many fellow rails developers are using jquery extensively now and some one may already solved my problem: rails'' RJS facility has helper methods like "replace_html", they allowed you to render partials in the .rjs file and execute the javascript which updates the page, how can I do that using jquery? Thanks in advance! Difei -- 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 -~----------~----~----~----~------~----~------~--~---
Difei Zhao wrote:> Greetings all, > > I think many fellow rails developers are using jquery extensively now > and some one may already solved my problem: > > rails'' RJS facility has helper methods like "replace_html", they > allowed you to render partials in the .rjs file and execute the > javascript which updates the page, how can I do that using jquery? > Thanks in advance! > > Difeinow I know "render :partial" works in js.erb, but why not "render :action"? A "render :action => :new" gives "Rendered resources/_new" in the log, why? Thanks! -- 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 -~----------~----~----~----~------~----~------~--~---
On Mon, Mar 2, 2009 at 11:31 PM, Difei Zhao <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Greetings all, > > I think many fellow rails developers are using jquery extensively now > and some one may already solved my problem: > > rails'' RJS facility has helper methods like "replace_html", they > allowed you to render partials in the .rjs file and execute the > javascript which updates the page, how can I do that using jquery? > Thanks in advance!I have this in my application.html.erb <script src="/javascripts/prototype.js" type="text/javascript"></script> <script src="/javascripts/effects.js" type="text/javascript"></script> <script src="/javascripts/dragdrop.js" type="text/javascript"></script> <script src="/javascripts/controls.js" type="text/javascript"></script> <script src="/javascripts/jquery.js" type="text/javascript"></script> <script src="/javascripts/jquery-ui.js" type="text/javascript"></script> <script src="/javascripts/application.js" type="text/javascript"></script> I have this in my application.js: var $j = jQuery.noConflict(); This puts the jQuery instance into it''s own namespace, leaving the $ object from prototype alone. And then in an rjs template I can do things like: page.replace_html ''pane_content'', :partial => ''message/sent_pane'' page << "$j($j.fn.nyroModal.settings.openSelector).nyroModal();" The page object still processes Javascript, no matter what library you use. -- Greg Donald http://destiney.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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Tue, 3 Mar 2009 20:25:58 -0600 Greg Donald <gdonald-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > On Mon, Mar 2, 2009 at 11:31 PM, Difei Zhao > <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: > > > > Greetings all, > > > > I think many fellow rails developers are using jquery extensively now > > and some one may already solved my problem: > > > > rails'' RJS facility has helper methods like "replace_html", they > > allowed you to render partials in the .rjs file and execute the > > javascript which updates the page, how can I do that using jquery? > > Thanks in advance!I have successfully used the jRails plugin. You just drop it in and it changes the built in JS jelpers to use jquery. http://ennerchi.com/projects/jrails -- Starr Horne My blog: http://starrhorne.com Check out my Helpdesk RailsKit: http://railskits.com/helpdesk/ --~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Wed, Mar 4, 2009 at 7:55 AM, Starr Horne <starr-wG8FsLYNbnsysxA8WJXlww@public.gmane.org> wrote:> I have successfully used the jRails plugin. You just drop it in and it changes the built in JS jelpers to use jquery. http://ennerchi.com/projects/jrailsWhen I tried it, about 4 or 5 months ago, it did work, but it didn''t play nice with prototype. Perhaps it''s improved since. -- Greg Donald http://destiney.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 -~----------~----~----~----~------~----~------~--~---
On Wed, 4 Mar 2009 08:08:45 -0600 Greg Donald <gdonald-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> When I tried it, about 4 or 5 months ago, it did work, but it didn''t > play nice with prototype. Perhaps it''s improved since.Ahh. Well I never it with prototype, so I couldn''t say. SH -- Starr Horne My blog: http://starrhorne.com Check out my Helpdesk RailsKit: http://railskits.com/helpdesk/ --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
johncgilliland-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2009-Mar-04 14:43 UTC
Re: rails w/ jquery
This may or may not answer your question, but I recently discovered a rails plugin called jrails which integrates jquery into rails very similar to the way prototype comes in rails. installing jrails allows you to use this: <%= javascript_include_tag :defaults %> to include jquery library files and there are other benefits and integrations, some of which i am pretty sure include helper methods for rjs. so i would try looking into the details for jrails... hope that helps... J On Mar 3, 12:31 am, Difei Zhao <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Greetings all, > > I think many fellow rails developers are using jquery extensively now > and some one may already solved my problem: > > rails'' RJS facility has helper methods like "replace_html", they > allowed you to render partials in the .rjs file and execute the > javascript which updates the page, how can I do that using jquery? > Thanks in advance! > > Difei > -- > 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-/JYPxA39Uh5TLH3MbocFFw@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 -~----------~----~----~----~------~----~------~--~---
Starr Horne wrote:> On Tue, 3 Mar 2009 20:25:58 -0600 > Greg Donald <gdonald-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> > allowed you to render partials in the .rjs file and execute the >> > javascript which updates the page, how can I do that using jquery? >> > Thanks in advance! > > > I have successfully used the jRails plugin. You just drop it in and it > changes the built in JS jelpers to use jquery. > http://ennerchi.com/projects/jrails > > > -- > Starr Horne > My blog: http://starrhorne.com > Check out my Helpdesk RailsKit: http://railskits.com/helpdesk/Hi, since I''d like write js code by hand with jquery, so "render :partial" in .js.erb file just fills my needs. -- 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 -~----------~----~----~----~------~----~------~--~---
Difei Zhao wrote:> Starr Horne wrote: >> On Tue, 3 Mar 2009 20:25:58 -0600 >> Greg Donald <gdonald-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >>> > allowed you to render partials in the .rjs file and execute the >>> > javascript which updates the page, how can I do that using jquery? >>> > Thanks in advance! >> >> >> I have successfully used the jRails plugin. You just drop it in and it >> changes the built in JS jelpers to use jquery. >> http://ennerchi.com/projects/jrails >> >> >> -- >> Starr Horne >> My blog: http://starrhorne.com >> Check out my Helpdesk RailsKit: http://railskits.com/helpdesk/ > > Hi, since I''d like write js code by hand with jquery, so "render > :partial" in .js.erb file just fills my needs.for newbies like me who don''t want to use jrails in rails 3 and might need it spelled out, rather than: render :update do |page| page.replace_html ''preview'', :partial => ''preview'' end do something like this in your controller: render :action => :preview and in your preview.js.erb file do something like: jQuery(''#preview'').html(''<%= javascript_escape(render(:partial => "preview")) %>''); of course, you''d also need a partial named _preview.erb (or _preview.haml) good luck! -- 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.
> and in your preview.js.erb file do something like: > > jQuery(''#preview'').html(''<%= javascript_escape(render(:partial => > "preview")) %>''); > > of course, you''d also need a partial named _preview.erb (or > _preview.haml) > > good luck!oops, should have said escape_javascript -- 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.