0

I have the following code working fine everywhere except Safari on Windows. Any suggestions how to fix it?

jQuery(document).ready(function() {
    // show the form
    // alert("hello");

    //jQuery(".tab3").attr('disabled', true);
    jQuery(".tab2").attr('disabled', false);
    jQuery(".tab3").attr('checked', true);
    jQuery(".tab2").attr('disabled', true);
    jQuery(".tab3").click();
    jQuery(".popUp").children('a').get(0).click();
});
Rory McCrossan
  • 331,213
  • 40
  • 305
  • 339
Ricky
  • 566
  • 3
  • 12

1 Answers1

2

Try this:

jQuery(document).ready(function() {
    jQuery(".tab2").attr('disabled', false);
    jQuery(".tab3").attr('checked', true);
    jQuery(".tab2").attr('disabled', true);
    var a1 = jQuery(".tab3");
    var a2 = jQuery(".popUp").children('a').get(0);
    var evObj1 = document.createEvent('MouseEvents');
    evObj1.initMouseEvent('click', true, true, window);
    var evObj2 = document.createEvent('MouseEvents');
    evObj2.initMouseEvent('click', true, true, window);

    a1.dispatchEvent(evObj1);
    a2.dispatchEvent(evObj2);
});

Source: jQuery .click() works on every browser but Safari

Community
  • 1
  • 1
campsjos
  • 1,275
  • 15
  • 22
  • Please, can you tell me where is the error so I can edit my answer. It can help other people with the same problem who arribes here. – campsjos Oct 05 '15 at 12:21
  • I have just commented var a1 = jQuery(".tab3"); and a1.dispatchEvent(evObj); – Ricky Oct 05 '15 at 12:34
  • But then `.tab3` click event isn't triggering, right? – campsjos Oct 05 '15 at 12:46
  • I've edited my answer to create a new event object. If works, please consider accept my answer. – campsjos Oct 05 '15 at 12:50
  • I have the same issue with ajax jQuery.ajax is not working on window safari. – Ricky Oct 05 '15 at 12:51
  • Do you have any solution why ajax jQuery.ajax is not working on window safari. – Ricky Oct 05 '15 at 12:51
  • You upvoted my answer, not [accepted](http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work) it :) You should open a new question, anyways look at this [thread](http://stackoverflow.com/questions/18778814/jquery-ajax-call-often-not-working-on-safari-6) – campsjos Oct 05 '15 at 12:55
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/91395/discussion-between-campsjos-and-rakesh). – campsjos Oct 05 '15 at 14:14