Martin Lang
Martin Lang

Reputation: 831

JavaScript issue with IE9 - Working without issue when Developer Toolbar is shown

I'm encountering quite a weird JavaScript Issue in IE9 (It works fine tough in Chrome, Safari, Firefox).

I have some JS that selects a different Color of an Image when you click on that associated swatch. In IE9, it seems that is completely ignoring this and it is simply doing nothing. But, as soon as I open up the F12 Developer Tools it starts working - Even without reloading the page. Am I mising something here?

jQuery

$('.product-details-description-colors .circle img').click(function() {

  if(!$(this).hasClass('oos')) {

    url = $(this).parent('label').data('image');
    color_value = $(this).parent('label').prev('input');
    color_value.prop('checked', true);

    $('.circle').find('input').not(color_value).attr('checked', false);
    $(this).css('outline', '1px solid black');
    $('.product-details-description-colors .circle img').not(this).css('outline', 'none');
    $('.product-details-images-showroom img').attr('src', url);

  }

});

Upvotes: 2

Views: 96

Answers (1)

Andrew Mao
Andrew Mao

Reputation: 36900

I assume you haven't posted all your code. One of the most common causes of this is trying to use the console object, specifically console.log. This is only available when the F12 tools are open and if they aren't, it will cause mysterious errors from propagating undefined.

Hence, this is a good idea to put somewhere in your coffeescript app:

# Fix IE logging issues
if not window.console
  window.console = 
    log: ->

Upvotes: 3

Related Questions