Reputation: 300
I have a fully functional backbone js application. In my controller, I retrieve my model from api through chained when.apply function calls. For example,
$.when.apply($, [<<array of deferred async calls>>]).done(function () {
<<Code to be executed after all deferred calls complete>>
});
This code has been working in latest firefox, chrome and IE10 browsers, but not in IE9. IE9 has not thrown any errors, but I see no calls made for loading the model data in network tab. Therefore the code to be executed after the call completes are not hit as well.
When searching for this issue I ran into this post. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/apply The post says,
Note: Most browsers, including Chrome 14 and Internet Explorer 9, still do not accept array-like objects and will throw an exception.
Is there a way around this without overhauling my existing code, which is a lot?
EDIT: After @Beetroot's comment below, it seems like backbone's fetch is to blame, which is used within the when.apply.
r = { method: 'get', body: { userId: loggedInUser } };
$.when.apply($, [employee.fetch(r), department.fetch(r)]).done(function () {
<<Code to be executed after all deferred calls complete>>
});
Again, when researching this issue, there are posts in SO like Backbone fetch() fails for IE, that suggest changing the fetch function to make it work in IE9. As mentioned above, we have hundreds of fetches in our application currently and it will set us back significantly if I have to rewrite these fetches. Is there any other way to fix this issue?
Upvotes: 0
Views: 1273
Reputation: 300
I finally spoke to somebody in MS support and they gave me this workaround in IE 9.
This works for me now in IE9. In IE10 and above even if that setting is disabled, the calls continue to work. I am guessing it has something to do with the underlying ajax call that is made through backbone sync, which uses XMLHTTPRequest in all modern browsers and is unable to do that in IE9 and below.
Upvotes: 1