Secret Orange Web Log

jQuery tabs and Stylish Select disabling all tabs in IE

There is an issue with an incompatibility beween jQuery tabs and The Stylish Select plugin.

Stylish Select defines Array.prototype.indexOf which doesn't well with jQuery.

Calling .tabs() will result in all tabs being disabled, apart from the selected tab (I've only noticed this in IE).

As a workaround I temporarily destroy the reference to indexOf, call tabs() then hook the reference back up again. Pop the code below into a common js file.

SecretOrange._ArrayIndexOfTempStorage = null;
SecretOrange.RemoveIndexOfReference = function() {
    SecretOrange._ArrayIndexOfTempStorage = Array.prototype.indexOf;
    Array.prototype.indexOf = null;
}

SecretOrange.RevertIndexOfReference = function() {
    Array.prototype.indexOf = SecretOrange._ArrayIndexOfTempStorage;
}

And then use:

SecretOrange.RemoveIndexOfReference();
$("#MyTabs").tabs();
SecretOrange.RevertIndexOfReference();
All should be fine.

jQuery shorthand for $(document).ready()

Have you been using:

$(document).ready(function() {
   // Do Stuff Here
});

Did you know you can simply just use the following syntax:

$(function() {
   // Do Stuff Here
});