Skip to content

Commit 83b087e

Browse files
committed
Fixed mar10#47: preventSelect option throws error on IE 6-8
1 parent 31b104b commit 83b087e

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

jquery.ui-contextmenu.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
},
4141
/** Constructor */
4242
_create: function () {
43-
var eventNames, targetId,
43+
var cssText, eventNames, targetId,
4444
opts = this.options;
4545

4646
this.$headStyle = null;
@@ -53,16 +53,24 @@
5353
// If the contextmenu was bound to `document`, we apply the
5454
// selector relative to the <body> tag instead
5555
targetId = ($(this.element).is(document) ? $("body") : this.element).uniqueId().attr("id");
56-
this.$headStyle = $("<style class='moogle-contextmenu-style' />")
57-
.prop("type", "text/css")
58-
.html("#" + targetId + " " + opts.delegate + " { " +
56+
cssText = "#" + targetId + " " + opts.delegate + " { " +
5957
"-webkit-user-select: none; " +
6058
"-khtml-user-select: none; " +
6159
"-moz-user-select: none; " +
6260
"-ms-user-select: none; " +
6361
"user-select: none; " +
64-
"}")
62+
"}";
63+
this.$headStyle = $("<style class='moogle-contextmenu-style' />")
64+
.prop("type", "text/css")
6565
.appendTo("head");
66+
67+
try {
68+
this.$headStyle.html(cssText);
69+
} catch( e ) {
70+
// issue #47: fix for IE 6-8
71+
this.$headStyle[0].styleSheet.cssText = cssText;
72+
}
73+
6674
// TODO: the selectstart is not supported by FF?
6775
if(supportSelectstart){
6876
this.element.delegate(opts.delegate, "selectstart" + this.eventNamespace, function(event){

jquery.ui-contextmenu.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)