2

I'm working with a solution using JQuery that was developed and tested in IE8.

I have a user, that had "Display all websites in Compatibility View" under Tools > Compatibility View Settings. And part of the JQuery Failed.

$(document).ready(function() {

    // creating named variables to represent the throbber objects to make life easier later.
    var moSearchThrobber = $("#imgSearchThrobber");
    var moFilterThrobber = $("#imgFilterThrobber");

    //lets hide the search and filter dialogs.
    $("div[id*=pnlSearch_Dialog]").hide();
    $("div[id*=pnlFilter_Dialog]").hide();

    // when I change the value of my drop downs in search and in filter, set the hidden field value.
    $("select[name=ddlValue]").change(function() {
        $(this).siblings("input:hidden").val($(this).val());
    });
    // If the user clicks on the Search link button.
    $("a[id*=lnkSearch").click(function() {

        // while we are at it turn on the search throbber
        moSearchThrobber.css('visibility', 'visible');

        // find the search grid and get/each through all the rows.
        $("table[id*=grdSearch]").find("tr").each(function() {

The hide functions work... but the click method fails to fire...

I've been looking at trying to force it into IE8 and turning off compatibility mode via the meta tag... but that feels dirty to me. Are there any other options at this point to make jquery work the same across all 3 "versions" of IE8?

Charles
  • 50,943
  • 13
  • 104
  • 142
Patrick
  • 7,512
  • 7
  • 39
  • 50
  • Did you get an error? What do you mean when you say it "failed"? – gilly3 Feb 02 '12 at 20:05
  • no error... it just didnt fire – Patrick Feb 02 '12 at 20:17
  • 1
    Filling in the blanks in your code, this works in IE9 in compatibility view: http://jsfiddle.net/WyyUe/. Note that you are missing an end bracket (`]`) in your `lnkSearch` selector, but that would break it whether in compatibility view or not, so I'm guessing that's just a typo. Can you post a jsfiddle where your bug can be seen? – gilly3 Feb 02 '12 at 20:39
  • /facepalm.... no WONDER it didn't work. im surprised it worked in ie8 quiet frankly (it was working just fine... which i dont understand). i ran the entire file thorugh http://www.javascriptlint.com/online_lint.php and it turns out I must not like the right bracket to much. I think what threw me is that there were no syntax errors in ie8 and it worked just fine w/o the right bracket. – Patrick Feb 03 '12 at 12:53

2 Answers2

4

Since my comment seemed to resolve your issue, I'm adapting it to an answer.

You are missing an end square bracket (]) in your lnkSearch selector. I would've expected that would break in IE8 and IE9, but apparantly document.querySelectorAll() accepts it. However, IE7 uses sizzle since it doesn't support document.querySelectorAll(). It seems sizzle does not like the malformed attribute selector.

Here's a test page with malformed attribute selectors. Switch between IE9, IE8, and IE7 modes and notice that it works in IE9 and IE8, but fails in IE7.

Here's the test page with corrected attribute selectors. Notice it works in all versions.

gilly3
  • 87,962
  • 25
  • 144
  • 176
2

I use the meta tag, as does HTML 5 Boilerplate and other reputable sources. But you're right, IE is a dirty business.

Edit:

According to Microsoft, IE=edge should always give you the latest rendering engine available. An exception would be intranet pages, which need to use IE=9 explicitly to avoid compatibility mode.

Rob Darwin
  • 942
  • 1
  • 10
  • 17
  • ok one quick question... what if someone is using IE9, and i put in that meta tag... while it force IE9 into some sort of IE8 compatibliity mode? and i'm just guessing that IE7 doesnt even know it exists so that would work ok? – Patrick Feb 02 '12 at 20:18