Fix incompatibility with JQuery UI v1.10. Closes #1668, Closes #1670.

Thanks to @vala and @xhj.