I have a site I'm working on that runs perfectly on Chrome for the desktop (Windows 8.1 & OS X Mavericks)
When I run it on iOS 7 or Safari 7.0.2 I get an error to the console that states
Error while loading route: checkIfLoggedIn
the member it specifies at the message is not a route, it is a method that returns a promise. When I debug through the ember code to figure out what is going wrong I found that it is rejecting the promise with the reason of
Can't find variable: Promise
I can't post the actual code from my site here, so I set out to create a fiddle that reproduces the error and I was able to come up with this:
http://jsfiddle.net/NQKvy/851/
This runs perfectly on Chrome for the desktop (Windows 8.1 & OS X Mavericks), but on iOS 7 or Safari 7.0.2 throws the following error to the console
ReferenceError: Can't find variable: Promise
Anyone have any ideas why this isn't working?
To recap:
This leads me to believe that it is a Safari error as (if I recall correctly) Chrome for iOS uses a Safari control to render the page rather than Chromium
This is the code I'm using to generate the error:
App.ready = function() {
var asdf = new Promise(function (resolve) {
var i = 1;
i++;
resolve.call(this,i);
}).then(function (result) {
alert('I: ' + result);
});
};
Turns out that on Safari you must use the fully qualified name when creating a promise, otherwise it will not work:
App.ready = function() {
var asdf = new Ember.RSVP.Promise(function (resolve) {
var i = 1;
i++;
resolve.call(this,i);
}).then(function (result) {
alert('I: ' + result);
});
};
Note the 'new Ember.RSVP.Promise' instead of the 'new Promise'. This appears to fix it for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With