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
routing not working with Phonegap 2.6 #174
Comments
forgot to mention that I tested it on Android 4 device an iOS 6 simulator. Both are having the same issue. And it seems that multi page template works well with angular routing. It works If the route is defined as |
I think that is expected behaviour. Think about it - you are asking for a url "/views/page1.html". What does that mean? The leading slash means "start from the root of the domain". When you are operating from your desktop browser, this means http://localhost:9000/views/page1.html or http://mydomain/views/page1.html But when you are operating in Cordova, there is no domain because you are working on the file:/// protocol. So the url "/views/page1.html" maps to file:///views/page1.html Obviously there is no such file /views/page1.html on your android operating system. So it fails. I had some luck in integrating jquery-mobile-angular-adapter with Cordova. But I had to call the templates with relative urls, not absolute:
There are still other issues getting anchors (<a href="") working such that they will from both http:// and file:/// - some of that can be solved by setting the base url in the jquery mobile page:
Still not sure if that's a good way of dealing with it or not, but it's working for me for now. |
Thanks . That solved my problem. Thought I have got another problem with form handling. ng-submit should prevent jquery mobiles form submit handling, and action attribute is not needed in the form. So the following code snippet should work.
But in my setup, it only works if the form is in index page. If the form in views/page1.html does not have action attribute, jquery mobile won't load it. #92 seems to be related. But the fix for #92 is to activate $.support.dynamicBaseTag, which is false by default. Have you encountered it before ? |
Yeah, I've had issues with preventing forms from submitting. I had to ensure that I specified a "src" attribute. I've forgotten why - obviously forms don't have src attributes. However, when I was debugging, I found that jQuery Mobile was expecting a src attribute.
|
It is related to $.support.dynamicBaseTag support. Looking at jQuery Mobile source, it is expecting to find action attributes and rewrite them. Adding src="" attribute to form tag would make the code go through without handling form submission; otherwise, thisUrl would be undefined if action attribute is not defined.
|
Looks like routing the index page is not working with Phonegap (2.6). When running on desktop / mobile browsers, the original index.html page might show up and then browser would switch to the view defined in routeProvider immediately. With phonegap, $routeChangeStart event isn't fired at all, and index.html shows up. Any ideas ? Thanks in advance.
|
Hi,
Tobias |
The Problem with form submitting is a known jqm bug: jquery-archive/jquery-mobile#4896 With this, all problems seems to be solved, except for 2. by @asgeo1. As I mentioned, please open another issue for this if needed... And thanks, @asgeo1 for providing the answers for 1. and 3.! Tobias |
I am trying the following simple setup using the adapter. The routing works on web browser, but fails on phonegap.
index.html
goto() function is defined in angularjs controller as
$scope.goto = function(path){$location.url(path);}
app.js
I have logged the pagebeforeload event. From the log, the relative path has been resolved to be in file:/// path !?
Any ideas ?
04-18 18:06:38.069: D/CordovaLog(32660): pagebeforeload:
04-18 18:06:38.069: I/Web Console(32660): pagebeforeload: at file:///android_asset/www/scripts/application.js:51
04-18 18:06:38.069: D/CordovaLog(32660): url:/views/page1.html
04-18 18:06:38.069: I/Web Console(32660): url:/views/page1.html at file:///android_asset/www/scripts/application.js:52
04-18 18:06:38.069: D/CordovaLog(32660): absUrl:file:///views/page1.html
04-18 18:06:38.069: I/Web Console(32660): absUrl:file:///views/page1.html at file:///android_asset/www/scripts/application.js:53
04-18 18:06:38.069: D/CordovaLog(32660): dataUrl:/views/page1.html
04-18 18:06:38.069: I/Web Console(32660): dataUrl:/views/page1.html at file:///android_asset/www/scripts/application.js:54
The text was updated successfully, but these errors were encountered: