javascript - How to load a new stylesheet when switching from JQuery Mobile site to PC site -
i using jquery mobile mobile site, , switching between , normal total pc site via mobile_device? method railscast#199
application_controller.rb
before_filter :prepare_for_mobile def mobile_device? if session[:mobile_param] session[:mobile_param] == "1" else request.user_agent =~ /mobile/ end end helper_method :mobile_device? def prepare_for_mobile session[:mobile_param] = params[:mobile] if params[:mobile] if mobile_device? if request.format == :js request.format = :mobilejs else request.format = :mobile end end end this method allows me switch jquery mobile site pc site.
<%= link_to "pc site", :mobile => 0 %> however, not load pc-site stylesheet. therefore, page has reloaded sec time css take affect.
how can load css on first try?
edit:
my stylesheets added separately application.html.erb , application.mobile.erb
application.html.erb
<%= stylesheet_link_tag "application" %> <%= javascript_include_tag "application" %> application.mobile.erb
<%= stylesheet_link_tag "mobile" %> <%= javascript_include_tag "mobile" %> # jquery mobile js file
the issue jquery mobile defaults ajax, needed disable follows.
<%= link_to "pc site", :mobile => 0, "data-ajax" => "false" %> javascript css ruby-on-rails
No comments:
Post a Comment