-
Notifications
You must be signed in to change notification settings - Fork 195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mobile-fu and jQuery Mobile #17
Comments
Try this code, maybe it will fix your issue:
|
Great! Thanks for the solution. |
@dmfrancisco You just saved my bacon! Thanks :-) |
Right, setting the request format to mobile definitely solve the issue, but why checking the ajax request at the first place in the method set_mobile_format? @benlangfeld, can you comment? Many thanks. |
I can't comment on the behaviour of mobile-fu as a plugin. If you find any issues with the gem, please file them on my fork as the code is completely different. |
But both the gem and the plugin share such method? https://github.com/benlangfeld/mobile-fu/blob/master/lib/mobile-fu.rb#L66 |
@gareth (benlangfeld@93d875d) or @revgum (benlangfeld@41dd15c) might recall the reason for this |
Afraid I can't shed any light on this. My commit was only to make |
I think I am having a similar problem. I wanted to add some more details. When using mobile_fu everything works fine until I try some ajax requests. I have an ajax action def ajax_select_user, after completion I call render
This code will call the associated select_user.js.erb which is expected. Inside select_user.js.erb I have some javascript to fill in some HTML. I call some partials in the .js.erb files
Now, I want selected_user.mobile.erb to be displayed since this is a mobile ajax request. selected_user.html.erb is called instead. |
Ok I have some more details on this. As it is mobile_fu will have difficulty with the scenario I put up. In an XHR request the type will be set to :js not :mobile. This is desired because we need the correct javascript response type. When in :js mode if you call render the ActionView will first look for :js (this is good for calling your .js.erb file) and will also look for :html. :html is hardcoded here https://github.com/rails/rails/blob/master/actionpack/lib/action_view/lookup_context.rb
Ideally it would be nice to change that fallback value dynamically somehow. From :html to :mobile if it's a mobile site. I'm not really sure how that could be done. I have found a workaround. I was able to add this code to the to of my .js.erb view template.
I imagine you could do something like this at the top of all of the .js.erb files used in ajax requests..
|
@lyslim if you set it to :mobile instead of :js then ajax requests don't work right. |
Yes, but I guess this could be done on controller side by calling the class method PS, I found setting the format directly also won't work when browsing full site from mobile device, as then we actually need html format. |
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. |
I am using mobile-fu with jQuery Mobile.
As you know, the jQuery Mobile convert a normal HTTP request to Ajax style request.
When I use mobile-fu with jQuery Mobile, It seems the mobile-fu doesn't understand mobile format and render the normal html template, not the mobile template.
Any Idea?
The text was updated successfully, but these errors were encountered: