opitzconsulting / jquery-mobile-angular-adapter

jquery mobile angular adapter
MIT License
517 stars 114 forks source link

Doesn't work with iOS 5 (simulator) #156

Closed mschwerdtfeger closed 11 years ago

mschwerdtfeger commented 11 years ago

It works fine with iOS 6 and PhoneGap (2.4) but if we try to run it on the iOS 5 simulator it shows only a white / blank page. When we comment out the angular adapter we can see the html, so it has something todo with the adapter.

We tried the standalone and the normal version:

Any ideas how to fix this?

Thanks in advance! Marc

mschwerdtfeger commented 11 years ago

We updated to PhoneGap 2.5 without any change.

tbosch commented 11 years ago

Hi, the problem is that running phonegap with ios simulator gives you a location like this: file:///Users/tbo/Library/Application Support/iPhone Simulator/.... In iOS6, location.href correctly replaces the blanks with %20, but with iOS 5, the blanks stay. As a consequence, angular gets into a $digest cycle problem, as it always sets the url with %20 but location.href returns it with blanks.

If you don't have blanks in the folder on your real mobile device, there should be no problem. However, I will commit a fix to also make this work in the simulator...

Tobias

tbosch commented 11 years ago

By the way, I traced the problem with the following snippet:

    document.addEventListener('deviceready', onDeviceReady, false);        
    function onDeviceReady() {
        angular.element(document).ready(function() {
            angular.bootstrap(document);
        });
    }

By this, angular will not initialize until phonegap is ready. And by this, phonegap will forward all console.log do the real console in the XCode debugger...

xliyong commented 11 years ago

Hi

I am still having the same issue with Phonegap 2.6 and iOS 5 simulator, thought it is working fine on iOS devices.

XCode debug log show index.html has been successfully loaded. Space was replaced with %20 correctly.

file:///Users/leyonh/Library/Application%20Support/iPhone%20Simulator/5.0/.../www/index.html

Tried remote debugging using weinre, and the console showed a few "TypeError: 'undefined' is not an object". I am not sure where did they come from, given that the same program works fine with iOS 6 simulator and iOS devices.

Running angular.bootstrap(document) manually in weinre console gave me TypeError: Cannot access caller property of a strict mode function

Do you have any idea how to fix this ?

Bootstrapping angular in onDeviceReady() function was not working for me. Is there any configuration needed ? I am using RequireJS.

xliyong commented 11 years ago

It turns out that error "TypeError: Cannot access caller property of a strict mode function" comes from weinre. With weinre script removed from index.html, I can manually bootstrap angularjs.

But the link still doesn't work in iOS5 simulator.

XCode shows an error message during AngularJS bootstrap {"message":"'undefined' is not an object"}

$routeChangeStart event always return next.ngmTemplateUrl = DEFAULT_JQM_PAGE ; pagebeforeload event shows the url is not routed by angularjs, and it still uses the url defined in html for page fetching.

Is there any way to check whether $routeProvider is actually properly loaded and working in AngularJS ?