Encountering an issue on Safari: Unable to locate the Promise variable

My website functions perfectly on Chrome for desktop (Windows 8.1 & OS X Mavericks). However, when I try to run it on iOS 7 or Safari 7.0.2, an error is displayed in the console that says:

Error while loading route: checkIfLoggedIn

The message specifies that the member is not a route, but rather a method that returns a promise. Upon debugging through the ember code, I discovered that the promise is being rejected with the reason:

Can't find variable: Promise

I am unable to share the actual code from my site here, so I attempted to create a fiddle to replicate the error. Here is the link to the fiddle:

http://jsfiddle.net/NQKvy/851/

This fiddle works fine on Chrome for Windows 8.1 and OS X Mavericks. However, on iOS 7 or Safari 7.0.2, it throws this error to the console:

ReferenceError: Can't find variable: Promise

Does anyone have any suggestions as to why this issue is occurring?

In summary:

  • Tested on Chrome for Windows 8.1 and OS X Mavericks - Works
  • Tested on Chrome for iOS - Does not work
  • Tested on Safari for iOS and OS X Mavericks - Does not work
  • Have not tested on Android yet

Based on my observations, I suspect it may be a Safari-related problem, considering that Chrome for iOS uses a Safari control to render pages instead of Chromium.

Here is the snippet of code causing 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);
    });
};

Answer №1

It turns out that Safari requires the fully qualified name when creating a promise in order for it to work correctly:

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);
    });
};

By using 'new Ember.RSVP.Promise' instead of 'new Promise', the issue was resolved.

Answer №2

The article on this website mentions that promises are not supported in iOS Safari 7.1 or Safari 7.

But there’s good news - they will be introduced in iOS Safari 8 and Safari 8!

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Initially, the 'display none' CSS command may not take effect the first time it is used

I am currently working on a slideshow application using jquery.transit. My goal is to hide a photo after its display animation by setting the properties of display, transform, and translate to 'none' value. Although the slideshow application work ...

What is the best way to retrieve data from ng-controller to use in the 'src' attribute of an <img> tag?

Check out this snippet of HTML: <div data-ng-controller="sampleCtrl" > <ul data-ng-repeat="item in sampleData"> <li class="message"> <img src="img-source" width="30" height="30"> <div class="message-text"> ...

Exploring the distinctions between Django template variables and JavaScript variables

I am currently trying to populate a table in a Django template. The challenge I am facing is comparing cell values between a JavaScript variable and a Django template variable within the same context. Is there a way to perform this comparison without conve ...

Customize the appearance of the Antd Select Component in multiple mode with checkbox styling

Is it possible to align the checkbox in the antd NPM package select component to the left in multiple mode, and style it like a tick mark followed by a label? Also, I need a separate search box as shown in the screenshot. I want to achieve this without usi ...

Utilizing jQuery's then() method to display HTML and JSON outputs from printing operations

Currently, I am in the process of mastering jquery deferreds. When working with html on jsfiddle, I receive an object that contains two lines when printed within the then() statement: "success" and the html returned by the ajax request. For instance, upo ...

Troubleshooting: Angular Binding Not Displaying

The structure of my directory is as follows: -flapper-news -app.js -index.html Within app.js, I have the following code: angular.module('flapperNews', []) .controller('MainCtrl', [ '$scope', function($scope){ $scope.t ...

I'm encountering issues with this code for a dice game. It's strange that whenever I click the roll dice button, it disappears. Additionally, linking an .css sheet seems to cause the entire page to

I'm currently working with two separate codes: one for HTML and the other for JavaScript. I am facing an issue where the button keeps disappearing when I try to add any CSS styling to it. Even a basic CSS file seems to override everything else and lea ...

Is there a way to prevent webpack from replacing process.env variables with their values during the build process?

Within one of my project files, I have the following snippet: const identifier = process.env.DBID; console.log('identifier', identifier); When I execute the command: cross-env PORT=4000 NODE_ENV=production WEBPACK_CONFIG=browser_prod,server_p ...

"Triggering a Javascript event upon re-launch of a mobile browser or waking up the

Hello everyone, I am in search of a Javascript event that can detect when a mobile browser window regains focus. This could happen when a user closes or minimizes their browser to switch back to the home screen or another app, or when the device resumes fr ...

The delegate consistently receives a null value in the dynamic framework class

When passing data from ViewController B to A in a dynamic framework using delegation, I encountered an issue. B is the dynamic framework's ViewController and A is my app's ViewController. Despite setting the delegate as self in my A class, it onl ...

I'm having trouble getting my bot command handler to function properly

When it comes to my command handler, the commands function properly. However, when I attempt to include arguments like $user-info @user instead of just $user-info, it returns an error stating that the command is invalid. Code //handler const prefix = &ap ...

ways to disrupt a timeout

I am attempting to incorporate a functionality similar to this example: https://www.w3schools.com/jsref/met_win_cleartimeout.asp On my personal website: If you enter certain characters in the input field, select one of them, and then pause for 5 seconds, ...

What is the best way to store data from multiple selected rows in different datagrids into a single state?

Programming Languages : JavaScript with React, Redux Toolkit, and Material-UI Issue : My goal is to synchronize the selection of checkboxes across multiple datagrids into one central state Attempts Made : I first attempted to manage checkbox selection fo ...

Highchart: precise positioning of ticks on axis

Is there a way to precisely determine the distance or establish an exact distance (in pixels) between two ticks on the x-axis using Highchart? I attempted to use tickPixelInterval, but it doesn't appear to accurately set the distance between two tick ...

Trigger controller redirection in AngularJS 1.5.0 by clicking on <tr> tag

Currently, I am facing an issue with my web page where I use the ng-repeat directive to populate a table with a list of companies. My goal is to have a functionality where clicking on a table row opens another page with a form to edit the selected company. ...

Error encountered during the creation of PDF file from Table View

I am currently facing an issue where I need to generate a PDF from a UITableView that contains multiple sections and rows. https://i.sstatic.net/G3k2b.png Although I have successfully generated the PDF, the problem lies in the fact that some rows are get ...

What is the process for incorporating personalized field attributes using an inlineformset_factory in Django?

I am currently working with an 'inlineformset_factory' and I am trying to determine the best way to set attributes for the individual fields. So far, I have not been able to find a method to add them without resorting to using javascript, which i ...

Encountering an error message stating "Unable to read property 'map' of undefined while attempting to create drag and drop cards

I have incorporated the library available at: https://github.com/clauderic/react-sortable-hoc The desired effect that I am aiming for can be seen in this example: https://i.stack.imgur.com/WGQfT.jpg You can view a demo of my implementation here: https:// ...

Refresh Highchart Data with Formatted AJAX Response

I have implemented a Highcharts scatterplot on my webpage with the following structure: $(function() { $('#container').highcharts({ /*chart options, etc... this does not change*/ series: [/*there is some default data ...

The specified file for import cannot be located or is unable to be read: node_modules/bootstrap/scss/functions

I am currently using core UI version 2.1.1 along with react. Upon attempting to execute npm start, I encountered the following error: (/Users/umairsaleem/Desktop/abc/abc/node_modules/css-loader??ref--6-oneOf-5-1!/Users/umairsaleem/Desktop/abc/abc/node_mo ...