sluggerdog
sluggerdog

Reputation: 843

jquery - on("change", function() not working in IE 9

I am having some issues with a jquery on function that works in all browsers except IE.

jquery code is as follows:

$('#FormIndustryId, #FormIndustries').on("change", function () {
  if ($(this).val()) {
    $.getJSON('/categories/list_categories/industry_id:' + $(this).val(),
    function (cats) {
      if (cats !== null) {
        populateCategorySelect(cats);
      }
    });
  }
});

From a front end point of view this can be tested here: http://www.beanclaim.com/ - there is a field with the label of industry selection which is the dropdown with #FormIndustries assigned to it, it should when an industry is selected update the second dropdown with the ajax content. Chrome, Firefox and Safari it works but it seems to do nothing in IE.

Any ideas what I am doing wrong? Thanks

Upvotes: 1

Views: 1105

Answers (2)

aquinas
aquinas

Reputation: 23786

It's because only in IE do you have this code execute:

// IF IE (BROWSER) USE jQUERY TO SET THE PLACEHOLDER
   // -------------------------------------------------->
    if ( $.browser.msie ) {
        $("#TemplateName").placeholder();
        $("#FormIndustries").placeholder();
    }

But, that returns this JS error:

SCRIPT438: Object doesn't support property or method 'placeholder' 

and stops your JS from executing properly. I don't know what placeholder is (and neither does IE :) ), but if you fix that, the page works just fine in IE.

Upvotes: 2

Kirk Backus
Kirk Backus

Reputation: 4866

Write the same exact function, but make a copy using:

$('#FormIndustryId, #FormIndustries').on("click", ...

Upvotes: 0

Related Questions