Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What can I use instead of the :indeterminate jQuery selector to avoid an exception in IE 8?

I have code like this

if ($('#chkCheckAll').is(':indeterminate') == true) 
{
}

But it is throwing exception in ie 8

what can do instead of this in Jquery to work with ie8

like image 625
Kuttan Sujith Avatar asked Jan 31 '13 12:01

Kuttan Sujith


2 Answers

Use this instead:

var $allChk = $('#chkCheckAll');
if ($allChk[0] && $allChk[0].indeterminate ) {
  ... 
}

The problem is that ':indeterminate' pseudo-expression is not supported by IE8 querySelectorAll implementation. But in your case, it's actually not required to use it, as you can query the corresponding property of DOM element itself

like image 88
raina77ow Avatar answered Oct 29 '22 23:10

raina77ow


Here is a great article http://css-tricks.com/indeterminate-checkboxes/

It SORT of works IE8 using .prop and has a hack too

<!-- Ghetto click handler -->
<input type="checkbox" id="cb1" onclick="ts(this)">function ts(cb) {
  if (cb.readOnly) cb.checked=cb.readOnly=false;
  else if (!cb.checked) cb.readOnly=cb.indeterminate=true;
}
like image 23
mplungjan Avatar answered Oct 29 '22 22:10

mplungjan