0

I am adding phpGrid tables in my site. I want the grids to be closed by default, but consulting the documentation I cannot find any argument to set this on initialization.

The grid is closed manually by clicking on an tag with the class "ui-jqgrid-titlebar-close". Using the following code at the bottom of the page I was able to get all of the grids closed up.

$(function() {
    // set the data-grids to appear closed by default
    $('.ui-jqgrid-titlebar-close').trigger('click');
    ...
} );

This works in Chrome, Firefox and IE9. Unfortunately this website is meant for internal access and IE9 falls back to "IE8 Standards mode" for intranet sites. In IE8 the click event has no effect.

Any ideas how to close my phpGrids in IE8?

Mr Griever
  • 4,014
  • 3
  • 23
  • 41
  • Is any of the other js code failing in IE8? are you getting any errors? what you have posted should work in IE8 (given the missing `)` at the end) – Kevin B Aug 28 '12 at 21:31
  • 1
    Why would IE9 run in IE8 mode for intranet sites? Seems silly to me... also, IE9's different modes don't _exactly_ replicate the actual browsers. I thought my site was broken in IE8 because of IE9's IE8 mode, but it actually works just fine in a real IE8 browser. – MrOBrian Aug 28 '12 at 21:32
  • @MrOBrian It's a security setting in IE (a default setting), when running on Intranet sites (sites that route to an internal ip) IE reverts to IE Compatibility mode (IE7 i believe) and it can't be overridden by the application. It's aimed at not breaking old intranet applications that were built for `OldIE` – Kevin B Aug 28 '12 at 21:34
  • You can try the work-around in this question http://stackoverflow.com/questions/3938215/jquery-trigger-not-working-in-ie-why – Hazem Salama Aug 28 '12 at 21:40
  • @KevinB so in order to maybe not break some old apps, they break all new ones... lovely. I test locally and thought localhost would be in the Intranet zone, but it's in the Internet zone. I add `` anyway to make sure IE isn't running in compatibility or quirks mode. – MrOBrian Aug 28 '12 at 21:45
  • The problem with the meta tag is I don't think it overrides the intranet zone setting. I haven't tested it myself, but there was an SO question dedicated to that problem. http://stackoverflow.com/questions/2742853/force-internet-explorer-8-browser-mode-in-intranet It's based on IE8, i'm not sure if IE9 follows the same rules. – Kevin B Aug 28 '12 at 21:51
  • @Kevin B so far as i can tell the other scripts on the page are working correctly. Thanks for pointing out the missing ")", I have edited my question and double-checked the code just in case. – Mr Griever Aug 29 '12 at 16:08
  • @MattH. The next test then would be `alert($('.ui-jqgrid-titlebar-close').length)` This will tell you if the problem is in the click event, or selecting the elements. – Kevin B Aug 29 '12 at 16:09
  • @hsalama Thank you for looking up that article. I have tried Mouhannad's solution but it did not work here. – Mr Griever Aug 29 '12 at 16:10
  • @Kevin B good thought. I added the .length alert immediately above the click trigger. I get an alert box with '5'. The boxes remain open. :D – Mr Griever Aug 29 '12 at 16:14
  • Now we need to inspect the click event. Where is the click event defined? where are you initializing jqgrid? – Kevin B Aug 29 '12 at 16:19

1 Answers1

0

Matt,

I have faced a similar issue before where IE defaults to compatibility mode for any intranet site and it is frustrating. You have a couple of options however.

If you have access to the web server, you can set the meta tag on your site properties, I did it on IIS, not sure about other web servers. But basically you need to add a Custom HTTP header where the name is X-UA-Compatible and the value is IE=9 (or edge if you prefer)

The other option is to include an IE shim (or shiv)

So using conditional comments you can do this

<!--[if lt IE 9]>
    <script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]-->

This script augments your browser capability to make it behave like IE9

Hazem Salama
  • 14,891
  • 5
  • 27
  • 31
  • I'm afraid the shim did not work in my case. I appreciate the effort, and hate to leave a question unanswered, so here ya go :) Hopefully i'll figure this thing out down the road. – Mr Griever Aug 30 '12 at 22:51