Reputation: 791
I am calling a function with jQuery as below in a RequireJS application. I get an error stating that "Object doesn't support this property or method" on IE8.
$(document).ready(function(){
if($("body").hasClass("js-splash-overlay")){
$("body").showSplashOverlay();
}
});
Splash overlay module.
'use strict';
define(['jquery'], function($){
return function(){
$.fn.showSplashOverlay = function() {
var $overlayData = $(this).find(".js-splash-data").html(),
$overlayContent = $("<div id=\"overlayHolder\" class=\"js-overlay-holder\">" + $overlayData + "</div>"),
$formElement = $("form")[0],
options = {
autoOpen: false,
closeOnEscape: false,
draggable: false,
autoResize:false,
hide: {
effect: "fade",
duration: 150
},
modal: true,
resizable: false,
show: {
effect: "fade",
duration: 150
},
width: 620,
maxWidth: 700,
minHeight:50,
fluid: true
};
$overlayContent.dialog(options).dialog("open");
setTimeout(function () {
$formElement.submit();
}, 1500);
return this;
};
}
});
First, I thought jQuery might not be present at the time the call happens. However, when I alert($("body").attr("class"))
it clearly shows the body class
. Hence it's obvious that jQuery is present at the time of calling.
Above work absolutely fine with Chrome, FF and other latest browsers. Unfortunately, we do have to support IE8 and requires the issue to be fixed.
JQuery Version : 1.11
RequireJS Version : 2.1.11
Many thanks and any advice or guidance is much appreciated. Happy to answer any questions.
UPDATE: The issue was a rogue code that IE8 didn't like. It's called splice
. Changing this to slice
seems to make it work.
Upvotes: 0
Views: 1264
Reputation: 791
In the end, the answer was nothing to do with RequireJS. I had a splice
command within my JS that somehow IE8 didn't like to work with. After changing the splice
to slice
.. it worked.
After much Googling around splice issue with early IE version, I have found that this issue is very common and has fixes from many people.
In my case, All I had to do was change
return Array.prototype.splice.call(arguments, 0);
to
return Array.prototype.slice.call(arguments, 0);
Upvotes: 1
Reputation: 245
IE browsers with switched-off dev mode will throw an exception when you refer to console object
Upvotes: 0