vaj oja
vaj oja

Reputation: 1161

JQuery event $(document).ready doesn't fire with mobile safari on IPhone 5

I use $(document).ready to fire the event. However, it works fine with IPHONE4S and IPHONE5S(both runs 7.1.1). But on IPHONE5(7.1.1), it doesnt fire at all.

When i change to window.onload, all work fine.

This confused me as all the IPhones are running exactly the same iOS. Why only IPHONE5 doesn't work with $(document).ready? Is this a bug of JQuery or iOS?

$(document).ready(
    function(){
    alert("fired");
});

window.onload=function(){
    if(navigator.userAgent.match(/iPhone/i))
    alert("fired");
}

Upvotes: 3

Views: 3356

Answers (1)

Pinke Helga
Pinke Helga

Reputation: 6682

Try the jQ plugin jQuery mobile or an older version of jQuery. jQ 1.6+ is known to cause problems on Safari/iPhone. I think it isn't a "bug", rather some special support of mobile devices is outsourced to a plugin in order to keep the the core slim.

Upvotes: 2

Related Questions