DAN
2006-Aug-09 00:19 UTC
[Rails] Can :before and :success move from view file into .rjs file?
Within the RJS template is there a way to specify when the visual_effect should occur? I''m trying not to repeat the :before and :success blind_down visual_effect statements throughout my views. It seems like the rjs templates can only take visual effects statements in the form of page.visual_effect :blind_up, ''divname''. I can''t figure out how to add :before or :success to this statement. Thanks, DAN -- Posted via http://www.ruby-forum.com/.
Kevin Olbrich
2006-Aug-10 05:13 UTC
[Rails] Can :before and :success move from view file into .rjs file?
On Wednesday, August 09, 2006, at 2:16 AM, DAN wrote:>Within the RJS template is there a way to specify when the visual_effect >should occur? > >I''m trying not to repeat the :before and :success blind_down >visual_effect statements throughout my views. > >It seems like the rjs templates can only take visual effects statements >in the form of >page.visual_effect :blind_up, ''divname''. I can''t figure out how to add >:before or :success to this statement. > >Thanks, >DAN > >-- >Posted via http://www.ruby-forum.com/. >_______________________________________________ >Rails mailing list >Rails@lists.rubyonrails.org >http://lists.rubyonrails.org/mailman/listinfo/railsTry out this plugin. http://rubyforge.org/projects/rjscallback It allows you to define rjs template files for the various callbacks and then links to them when appropriate. _Kevin www.sciwerks.com -- Posted with http://DevLists.com. Sign up and save your mailbox.
Mark Reginald James
2006-Aug-10 06:34 UTC
[Rails] Re: Can :before and :success move from view file into .rjs file?
DAN wrote:> Within the RJS template is there a way to specify when the visual_effect > should occur? > > I''m trying not to repeat the :before and :success blind_down > visual_effect statements throughout my views. > > It seems like the rjs templates can only take visual effects statements > in the form of > page.visual_effect :blind_up, ''divname''. I can''t figure out how to add > :before or :success to this statement.By :before do you mean :loading? If so, all these pre-response phases must be encoded in the view. To avoid repeating your effect calls you can put them in your own Javascript function, in an included .js file, and then just refer to your function in your remote calls. RJS is just an easy way to build an executable response sequence to Ajax requests. So to restrict execution of the RJS effects to :success you need to ensure that this RJS is only built if everything went OK, and if it didn''t, to either render some other RJS, or to set the response status to 500, render nothing, and signal failure in some way e.g.: :failure => "alert(''Remote function failed'')" -- We develop, watch us RoR, in numbers too big to ignore.