Is there a way to use any kind of helper or something if you do the same thing on every rjs call? Like render a flash box div? -- 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.
Chris Habgood wrote:> Is there a way to use any kind of helper or something if you do the > same thing on every rjs call? Like render a flash box div?Why not write JavaScript directly in unobtrusive style, and call the appropriate function as necessary? Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- 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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
It is a full ajax site. flash gets rendered on every call, nothing in it if it is empty anyway. On Feb 11, 11:06 am, Marnen Laibow-Koser <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Chris Habgood wrote: > > Is there a way to use any kind of helper or something if you do the > > same thing on every rjs call? Like render a flash box div? > > Why not write JavaScript directly in unobtrusive style, and call the > appropriate function as necessary? > > Best, > -- > Marnen Laibow-Koserhttp://www.marnen.org > mar...-sbuyVjPbboAdnm+yROfE0A@public.gmane.org > -- > 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.
Please quote when replying -- otherwise we don''t know what you''re responding to. Chris Habgood wrote:> It is a full ajax site. flash gets rendered on every call, nothing > in it if it is empty anyway.So what? That''s irrelevant to the advice I gave, isn''t it? Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- 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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Ok, how would I implement the manual JS version to get called automatically on every rjs render? On Feb 11, 11:56 am, Marnen Laibow-Koser <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Please quote when replying -- otherwise we don''t know what you''re > responding to. > > Chris Habgood wrote: > > It is a full ajax site. flash gets rendered on every call, nothing > > in it if it is empty anyway. > > So what? That''s irrelevant to the advice I gave, isn''t it? > > Best, > -- > Marnen Laibow-Koserhttp://www.marnen.org > mar...-sbuyVjPbboAdnm+yROfE0A@public.gmane.org > -- > 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.
For the second time: please quote when replying! Chris Habgood wrote:> Ok, how would I implement the manual JS version to get called > automatically on every rjs render?Why do you need RJS? Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- 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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
" Why do you need RJS? " It is an ajax call On Feb 11, 12:04 pm, Marnen Laibow-Koser <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> For the second time: please quote when replying! > > Chris Habgood wrote: > > Ok, how would I implement the manual JS version to get called > > automatically on every rjs render? > > Why do you need RJS? > > Best, > -- > Marnen Laibow-Koserhttp://www.marnen.org > mar...-sbuyVjPbboAdnm+yROfE0A@public.gmane.org > -- > 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.
Chris Habgood wrote:> " Why do you need RJS? " > > It is an ajax callThat doesn''t require RJS. Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- 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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
"That doesn''t require RJS." Ok, this is an early build out I do not want updates in the controller ase may have additional stuff in the future and i do not want the controller cluttered up. On Thu, Feb 11, 2010 at 12:27 PM, Marnen Laibow-Koser <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>wrote:> Chris Habgood wrote: > > " Why do you need RJS? " > > > > It is an ajax call > > That doesn''t require RJS. > > Best, > -- > Marnen Laibow-Koser > http://www.marnen.org > marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org > -- > 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > 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-/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.
Chris Habgood wrote:> "That doesn''t require RJS." > > Ok, this is an early build out I do not want updates in the controller > ase > may have additional stuff in the future and i do not want the controller > cluttered up. > > On Thu, Feb 11, 2010 at 12:27 PM, Marnen Laibow-KoserWho said anything about cluttering the controller? RJS serves no useful purpose as far as I can see (I could be wrong). Anyway, you''re being so vague about the structure of your app that it''s not possible to help. Try providing more information. Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- 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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Thu, Feb 11, 2010 at 12:27 PM, Marnen Laibow-Koser <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Chris Habgood wrote: >> " Why do you need RJS? " >> >> It is an ajax call > > That doesn''t require RJS.Why the war on RJS? It''s been working great for me since Rails 0.8. -- 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.
On Thu, Feb 11, 2010 at 12:39 PM, Marnen Laibow-Koser <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Who said anything about cluttering the controller? RJS serves no useful > purpose as far as I can see (I could be wrong).Serves no useful purpose? The one I wrote a few minutes ago seems damn useful to me and my app. The 98349837498 RJS files I''ve written previously also seem very useful. I think what''s useless here is most of what you post. -- 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.
"Anyway, you''re being so vague about the structure of your app that it''s not possible to help. Try providing more information." It is a full ajax app. Meaning, the only real page refreshes are when logging in and out. We have a ton of ajax calls. I was just trying to DRY up the rjs files if we load the flash box on every call. On Thu, Feb 11, 2010 at 12:39 PM, Marnen Laibow-Koser <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>wrote:> Chris Habgood wrote: > > "That doesn''t require RJS." > > > > Ok, this is an early build out I do not want updates in the controller > > ase > > may have additional stuff in the future and i do not want the controller > > cluttered up. > > > > On Thu, Feb 11, 2010 at 12:27 PM, Marnen Laibow-Koser > > Who said anything about cluttering the controller? RJS serves no useful > purpose as far as I can see (I could be wrong). > > Anyway, you''re being so vague about the structure of your app that it''s > not possible to help. Try providing more information. > > Best, > -- > Marnen Laibow-Koser > http://www.marnen.org > marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org > -- > 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > 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-/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.
Greg Donald wrote:> On Thu, Feb 11, 2010 at 12:27 PM, Marnen Laibow-Koser > <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >> Chris Habgood wrote: >>> " Why do you need RJS? " >>> >>> It is an ajax call >> >> That doesn''t require RJS. > > Why the war on RJS?What war? It doesn''t seem to be serving the OP well.> It''s been working great for me since Rails 0.8.How do you keep the generated JavaScript out of your HTML?> > > -- > Greg Donald > destiney.com | gregdonald.comBest, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- 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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Greg Donald wrote:> On Thu, Feb 11, 2010 at 12:39 PM, Marnen Laibow-Koser > <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >> Who said anything about cluttering the controller? �RJS serves no useful >> purpose as far as I can see (I could be wrong). > > Serves no useful purpose? The one I wrote a few minutes ago seems > damn useful to me and my app.Let''s see it! I''m always willing to learn.> The 98349837498 RJS files I''ve written > previously also seem very useful.You''ve lived for millennia and written an RJS file every second? Fascinating!> > I think what''s useless here is most of what you post.Personal attacks do not belong on this list, or any other.> > > -- > Greg Donald > destiney.com | gregdonald.comBest, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- 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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Thu, Feb 11, 2010 at 12:42 PM, Marnen Laibow-Koser <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:>> Why the war on RJS? > > What war? It doesn''t seem to be serving the OP well.And since by your own admission you know little to nothing about RJS templates, what makes you an authority to dismiss them as "useless"?>> It''s been working great for me since Rails 0.8. > > How do you keep the generated JavaScript out of your HTML?Partials. -- 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.
On Thu, Feb 11, 2010 at 12:47 PM, Marnen Laibow-Koser <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Personal attacks do not belong on this list, or any other.Well someone had to say something, I''m sick of reading the crap you post. -- 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.
Greg Donald wrote:> On Thu, Feb 11, 2010 at 12:42 PM, Marnen Laibow-Koser > <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >>> Why the war on RJS? >> >> What war? �It doesn''t seem to be serving the OP well. > > And since by your own admission you know little to nothing about RJS > templates, what makes you an authority to dismiss them as "useless"? >I don''t claim to be one. I''m no RJS expert, and I do plan to look at RJS in more detail the next time I need significant amounts of JavaScript in a project. But I *am* an expert JavaScript programmer, and I really do not see the advantage of *not* writing my JavaScript directly. Why do you prefer RJS to writing JavaScript?>>> �It''s been working great for me since Rails 0.8. >> >> How do you keep the generated JavaScript out of your HTML? > > Partials. > >Wouldn''t that still put the JavaScript into your HTML files?> -- > Greg Donald > destiney.com | gregdonald.comBest, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- 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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Thu, Feb 11, 2010 at 12:58 PM, Marnen Laibow-Koser <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Why do you prefer RJS to writing JavaScript?RJS is a template rendering system that also happens to execute JS. I do not prefer one over the other, it''s apples and oranges. Controller action: def get_user if request.xhr? @user = User.find( params[:id] ) end end get_user.rjs: if @user page.replace_html ''user_tab'', :partial => ''user/user_form'' page << "$j( ''#user_tab'' ).fadeIn(''slow'');" end>>> How do you keep the generated JavaScript out of your HTML? >> >> Partials. >> > Wouldn''t that still put the JavaScript into your HTML files?Yup. -- 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.
Greg Donald wrote:> On Thu, Feb 11, 2010 at 12:47 PM, Marnen Laibow-Koser > <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >> Personal attacks do not belong on this list, or any other. > > Well someone had to say something, I''m sick of reading the crap you > post.Then don''t read it and don''t make attacks like this. I''m sure everyone has posters they feel this way about -- I know I do -- but we don''t say that kind of thing.> > > -- > Greg Donald > destiney.com | gregdonald.comBest, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- 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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Thu, Feb 11, 2010 at 1:15 PM, Marnen Laibow-Koser <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Then don''t read it and don''t make attacks like this. I''m sure everyone > has posters they feel this way about -- I know I do -- but we don''t say > that kind of thing.I saw what I feel like saying, especially to big mouth blow-hards like yourself. -- 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.
Ok, does anyone know how to do a page[:div].replace_html on every ajax call, helper or something like that? On Feb 11, 1:15 pm, Greg Donald <gdon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Thu, Feb 11, 2010 at 12:58 PM, Marnen Laibow-Koser > > <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: > > Why do you prefer RJS to writing JavaScript? > > RJS is a template rendering system that also happens to execute JS. I > do not prefer one over the other, it''s apples and oranges. > > Controller action: > > def get_user > if request.xhr? > @user = User.find( params[:id] ) > end > end > > get_user.rjs: > > if @user > page.replace_html ''user_tab'', :partial => ''user/user_form'' > page << "$j( ''#user_tab'' ).fadeIn(''slow'');" > end > > >>> How do you keep the generated JavaScript out of your HTML? > > >> Partials. > > > Wouldn''t that still put the JavaScript into your HTML files? > > Yup. > > -- > 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:> On Thu, Feb 11, 2010 at 12:58 PM, Marnen Laibow-Koser > <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >> Why do you prefer RJS to writing JavaScript? > > RJS is a template rendering system that also happens to execute JS. I > do not prefer one over the other, it''s apples and oranges.OK. Perhaps I should have asked *when* you prefer RJS.> > Controller action: > > def get_user > if request.xhr? > @user = User.find( params[:id] ) > end > end > > get_user.rjs: > > if @user > page.replace_html ''user_tab'', :partial => ''user/user_form'' > page << "$j( ''#user_tab'' ).fadeIn(''slow'');" > endHmm. Why the visual effect here, rather than in the completion handler for the Ajax call? I guess I don''t see the point of Rails writing JS, rather than simply handing a JSON packet to the client. I''ll think about this further, though.> >>>> How do you keep the generated JavaScript out of your HTML? >>> >>> Partials. >>> >> Wouldn''t that still put the JavaScript into your HTML files? > > Yup.Which I don''t like to do. Thanks for confirming that this is actually the case.> > > -- > Greg Donald > destiney.com | gregdonald.comBest, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- 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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Thu, Feb 11, 2010 at 1:33 PM, Marnen Laibow-Koser <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:>>> Wouldn''t that still put the JavaScript into your HTML files? >> >> Yup. > > Which I don''t like to do. Thanks for confirming that this is actually > the case.link_to_remote, button_to_remote, periodically_call_remote, submit_to_remote, and remote_form_for all write JS directly into the HTML. Good thing you don''t use those. -- 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.
Hi Marnen, On Thu, 2010-02-11 at 20:33 +0100, Marnen Laibow-Koser wrote:> I guess I don''t see the point of Rails writing JS, > rather than simply handing a JSON packet to the client.Reduced application complexity. Best regards, Bill -- 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 Thu, Feb 11, 2010 at 1:33 PM, Marnen Laibow-Koser <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:>> get_user.rjs: >> >> if @user >> page.replace_html ''user_tab'', :partial => ''user/user_form'' >> page << "$j( ''#user_tab'' ).fadeIn(''slow'');" >> end > > Hmm. Why the visual effect here, rather than in the completion handler > for the Ajax call?Because I build more than just toy apps. Sometimes I have complex logic for what effect to show, or what to do when an exception is raised. Sometimes the JS is generated, like: page << "$j(function(){ $j.notifyBar({ html: ''#{ "Enrollment goals updated" }'', delay: #{ FLASH_EXPIRE_DELAY }, animationSpeed: ''normal'' }); });"> I guess I don''t see the point of Rails writing JS,I agree, you do not. -- 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:> On Thu, Feb 11, 2010 at 1:33 PM, Marnen Laibow-Koser > <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >>>> Wouldn''t that still put the JavaScript into your HTML files? >>> >>> Yup. >> >> Which I don''t like to do. �Thanks for confirming that this is actually >> the case. > > link_to_remote, button_to_remote, periodically_call_remote, > submit_to_remote, and remote_form_for all write JS directly into the > HTML. Good thing you don''t use those.Exactly. I''m looking forward to being able to use them in Rails 3, but till then I can''t.> > > -- > Greg Donald > destiney.com | gregdonald.comBest, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- 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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Greg Donald wrote:> On Thu, Feb 11, 2010 at 1:33 PM, Marnen Laibow-Koser > <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >>> get_user.rjs: >>> >>> if @user >>> � page.replace_html ''user_tab'', :partial => ''user/user_form'' >>> � page << "$j( ''#user_tab'' ).fadeIn(''slow'');" >>> end >> >> Hmm. �Why the visual effect here, rather than in the completion handler >> for the Ajax call? > > Because I build more than just toy apps.So do I.> Sometimes I have complex > logic for what effect to show, or what to do when an exception is > raised. Sometimes the JS is generated, like: > > page << "$j(function(){ $j.notifyBar({ html: ''#{ "Enrollment goals > updated" }'', delay: #{ FLASH_EXPIRE_DELAY }, animationSpeed: ''normal'' > }); });"I''d consider that problematic application design, but again, I''ll think about it further. I''d rather let the client-side JS make this decision.> >> I guess I don''t see the point of Rails writing JS, > > I agree, you do not. > > > -- > Greg Donald > destiney.com | gregdonald.comBest, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- 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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Feb 11, 4:57 pm, Me <chabg...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Is there a way to use any kind of helper or something if you do the > same thing on every rjs call? Like render a flash box div?if in a helper you stick something like def rjs_flash update_page do |page| ... end end Then in your templates you can do page << rjs_flash You can also do stuff like link_to_function(''Foo'', rjs_flash) if you use those helpers. (First saw this trick at rails conf europ a few years ago, slides to the talk are here: http://www.slideshare.net/RubyOnRails_dude/marcel-molina-jr-presentation Fred -- 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.
Thanks. I was not sure if there was a totally transparent way to do. On Thu, Feb 11, 2010 at 3:41 PM, Frederick Cheung < frederick.cheung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > On Feb 11, 4:57 pm, Me <chabg...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Is there a way to use any kind of helper or something if you do the > > same thing on every rjs call? Like render a flash box div? > > if in a helper you stick something like > > def rjs_flash > update_page do |page| > ... > end > end > > Then in your templates you can do > > page << rjs_flash > > You can also do stuff like link_to_function(''Foo'', rjs_flash) if you > use those helpers. (First saw this trick at rails conf europ a few > years ago, slides to the talk are here: > http://www.slideshare.net/RubyOnRails_dude/marcel-molina-jr-presentation > > Fred > > -- > 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > 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-/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 Thu, Feb 11, 2010 at 2:19 PM, Marnen Laibow-Koser <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:>> I''d rather let the client-side JS make this decision.The client side wouldn''t yet know if my record was successfully saved to the db or not. -- 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:> > link_to_remote, button_to_remote, periodically_call_remote, > submit_to_remote, and remote_form_for all write JS directly into the > HTML. Good thing you don''t use those. >In Rails3 these have all been made unobtrusive. -- 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 Fri, Feb 12, 2010 at 4:44 AM, Andrew Porter <andy-OV3k8GMR8cdg9hUCZPvPmw@public.gmane.org> wrote:> Greg Donald wrote: >> >> link_to_remote, button_to_remote, periodically_call_remote, >> submit_to_remote, and remote_form_for all write JS directly into the >> HTML. Good thing you don''t use those. >> > > In Rails3 these have all been made unobtrusive.Yup, but it doesn''t mean the old way is suddenly wrong. -- 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.
On Feb 11, 7:46 pm, Greg Donald <gdon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Thu, Feb 11, 2010 at 1:33 PM, Marnen Laibow-Koser > Because I build more than just toy apps. Sometimes I have complex > logic for what effect to show, or what to do when an exception is > raised. Sometimes the JS is generated, like: > > page << "$j(function(){ $j.notifyBar({ html: ''#{ "Enrollment goals > updated" }'', delay: #{ FLASH_EXPIRE_DELAY }, animationSpeed: ''normal'' > > }); });" > > I guess I don''t see the point of Rails writing JS,Personally I use rjs when it''s a good fit, and when it''s not I don''t - RJS is fine for the simple stuff but sometimes it just doesn''t feel like it''s worth the effort to massage something into RJS language instead of writing plain javascript - plain old js.erb is easier there. I also don''t like writing anything too complicated like this (rjs or js.erb) because I find it awkward to test. It''s way simpler to write unit tests that assert that the server side code produces the correct json fragments and then some javascript unit tests to assert that the various possible json payloads are consumed properly. -- 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:> On Thu, Feb 11, 2010 at 2:19 PM, Marnen Laibow-Koser > <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >>>�I''d rather let the client-side JS make this decision. > > The client side wouldn''t yet know if my record was successfully saved > to the db or not.Then that information could be in the JSON packet, because the server *would* know at the appropriate time. All it would need is one more field. It seems to me that in most cases, there''s something conceptually wrong with sending *behavior* in the way you''re describing, rather than *data*. I tend to think that if the client sends an Ajax request for (say) a record to the server, it should get back data for that record, which it can then decide how to render. This would also presumably make it easier to use the same JSON API for both internal Ajax and external Web-service consumers. It also means that JS files can be static, and thus cacheable by the browser. I like the simplicity of the RJS approach for certain trivial cases (and perhaps for cases where behavior, rather than data, is primarily what the client is requesting), but I''m finding difficulty in seeing how it can scale well or be maintainable. I''ll probably play around with it at some point soon and see if I''m missing something that would change my mind.> > > -- > Greg Donald > destiney.com | gregdonald.comBest, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- 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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Greg Donald wrote:> > Yup, but it doesn''t mean the old way is suddenly wrong. > > > -- > Greg Donald > destiney.com | gregdonald.comRJS is difficult to test and especially difficult to debug when things go wrong. I would have to agree with Fred that it''s just less complicated to stay away from RJS. When you need javascript, just write javascript. And, yes, Marnen has a style of writing that may seem elitist at times, but his arguments serve a purpose. He wants to force a definitive answer if it can exist. I''ve gotten into many arguments (most positive) with him and in many of those, sometimes I want to yank the strings out of his violin. But, then I calm down and slowly re-read what he''s posting and remove any and all tones I might see in the argument. What I got from Marnen''s arguments in this topic were that RJS is more complicated, more often it is clearly unnecessary to use, and it''s just better to write .. javascript. All of those points are pretty clear and true. Greg, some of your own points are pretty clear as well and if you''ve perfected your RJS templates and they work great in your projects, I see no reason not to reuse them again, if you are happy with them. However, everything changes and RJS is becoming less used. Just keep that in mind. -- 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 Fri, Feb 12, 2010 at 12:16 PM, Alpha Blue <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Greg, some of your own points are pretty clear as well and if you''ve > perfected your RJS templates and they work great in your projects, I see > no reason not to reuse them again, if you are happy with them.Thank goodness.. I''ll be able to sleep tonight. -- 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.