sur says ajax :on => rails

Friday, June 02, 2006

DO NOT GO FOR RJS TEMPLATES


RJS is undoubtly a good method of ajaxification of your web application.
But why to have another myaction.rjs file if its functionality could be merged
within the action itself.
Is it possible ?

Oh !!! its like applying butter on bread.......... check this out




class MyController < ApplicationController
def myaction
render :update do ¦ page ¦
page.replace_html 'update_this_element_id', :partial=>update_from_controller/update_partial_file'
# and all your effects of scrip.aculo.us as we do put in your myaction.rjs
end
end
end


Well, atleast you can avoid myaction.rjs files for just some render partials or a few special effects or when you can afford to not to separate your rjs code.


Well, RJS beautifully continues the MVC behaviour but,
in some cases it might be better to to go for the above one.


So dont feel hazi, you can try it for a while.



0 Comments:

Post a Comment

<< Home