Patch to fix incompatibility with jquery 1.8

From #4938.