mobile-fu rjs
hm… hm… hm… hm
I’m a bit unsatisfied with mobile-fu for rails. Sure, it’s great in general, but I want to have different templates for mobile rjs and default rjs and i think it’s a bit clumsy to do it like that:
application.html.erb
def mobile?
return session[:mobile_view]
end
# distinct between mobile and non-mobile js (mobile-fu)
# only supports :template paramter for mobile-enabled js
def render_mobilized_js(options = nil)
# if we’re not mobile => render like there is no mobile
unless mobile?
return render options if options
return render
end
# render mobilized rjs template
ops = (options || {}).dup
ops[:template] ||= “#{controller_name}/#{action_name}”
ops[:template] += “.mobile_js.rjs”
return render ops
end
but now I’m able to do this
respond_to do |format|
format.html
format.js { render_mobilized_js }
end
But in an ideal world i don’t want to call render at all. I want rails or mobile-fu to do it for me:
respond_to do |format| format.html format.js format.mobile_js end
Not yet possible - and if it would be possible it would break dependencies. Therefore i keep using my method - unless anyone points me a step towards the elegant solution… anyone?