brendanlim/mobile-fu

set_mobile_format's XHR filter breaks jQuery Mobile

mattg opened this issue · 8 comments

set_mobile_format assumes that XHR requests should not use the :mobile format. I'm not sure it should have an opinion about this. jQuery Mobile makes XHR requests expecting that it will get the mobile version of a page. I really want to use jQuery Mobile, so I made the following very ugly patch in my copy:

if is_mobile_device? && !request.xhr?

to:

if is_mobile_device? && ['/','text/html'].include?(request.format)

Maybe this could be a configuration option.

I ran into this too, it took quite a bit of debugging since it only happens in production mode.

Maybe we could have a method like should_use_mobile_format that defaults to if is_mobile_device? && !request.xhr?. This would allow jquery mobile users, or others, override it easily in application_controller.

I am hitting the exact same issue (or so I think ...). None of my pages are rendering properly on a mobile device as soon as I enable Mobile fu.

I am not sure if I understand the fix above. Is there a way to force the output stream to be set mobile without changing the underlying plugin?

Thanks

ankitb, are you using jQuery Mobile? If not, then you have a different problem.

Yes I am using jquery mobile.

There is a way to force the output to be mobile, but it behaves differently from when it happens on its own. Are you just getting blank pages?

I'm with the same problem, using jQuery Touch from Sencha Labs.

@mattg did u fix this like on your first post?

I did. I've since made more modifications. I really need to make a fork.

This project is abandoned. Please see the active fork at http://github.com/benlangfeld/mobile-fu. Please test with the released gem and master branch of the new home for the project, and file an issue on the other repo if you still have problems.

See #40.