Search code examples
javascriptjqueryjsbin

jsbin does not recognize document ready in IE


See: http://jsbin.com/ebudec/edit#javascript,html


It seems strange but I think jsBin doesn't recognize the jQuery document ready (other syntax - which I use a lot) in IE :

$(function () {});

jQuery.ready says :

The .ready() method is typically used with an anonymous function:

$(document).ready(function() {
  // Handler for .ready() called.
});

Which is equivalent to calling:

$(function() {
 // Handler for .ready() called.
});

Solution

  • I added the following test code to your jsbin:

    $(document).ready(function () {alert('');}); // Works!
    $(function () {alert('');}); // Fails
    

    The second line most definitely throws an error in IE. The interesting thing is that the IE debugger showed the following markup:

    <script>
    window.onload = (function () {alert('');});
    $(function () {alert('');});
    </script>
    

    The debugger also did not have the $ or jQuery objects defined. It looks like jsbin was somehow trying to parse out the jQuery code???