Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Remove inline onclick handlers #417

Closed
wants to merge 1 commit into from

3 participants

@timoxley

Using your plugin in a chrome extension, and chrome forbids inline onclick handlers:

Refused to execute inline event handler because it violates the following Content Security Policy directive: "script-src 'self' chrome-extension-resource:".

See http://developer.chrome.com/extensions/contentSecurityPolicy.html

I've removed the two instances on onclick from select2. The first instance I swapped out to use your killEvent helper and the second one was superfluous since killEvent was being called in the handler anyway.

@ivaynberg
Owner

this was added as part of #330, any ideas?

@timoxley

Yeah no idea, I don't currently have an IE to test on so that kinda sucks.

@timoxley

From what I can tell from the link he posted, the actual solution is only dependent on the href="#" instead of href="javascript:void(0)", but I have no way to test this assertion.

@kevin-brown
Owner

The issue in #330 is now back in play because #487 had to reintroduce the changed line. Chosen fixed this previously by just stopping the propagation of the click, which seems like a really simple solution.

harvesthq/chosen#337

@timoxley

@kevin-brown yep, that was my thinking. This fix does kill the click event, so I'd be interested if it possibly solves both issues.

@ivaynberg
Owner

closing until a viable solution is found.

@ivaynberg ivaynberg closed this
@rice rice referenced this pull request
Merged

Remove inline styles #1180

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 16, 2012
  1. @timoxley
This page is out of date. Refresh to see the latest.
Showing with 3 additions and 3 deletions.
  1. +3 −3 select2.js
View
6 select2.js
@@ -1389,7 +1389,7 @@
var container = $("<div></div>", {
"class": "select2-container"
}).html([
- " <a href='#' onclick='return false;' class='select2-choice'>",
+ " <a href='#' class='select2-choice'>",
" <span></span><abbr class='select2-search-choice-close' style='display:none;'></abbr>",
" <div><b></b></div>" ,
"</a>",
@@ -1488,7 +1488,7 @@
}
}
}));
-
+ this.selection.bind("click", killEvent)
this.search.bind("focus", this.bind(function() {
this.selection.attr("tabIndex", "-1");
}));
@@ -2052,7 +2052,7 @@
var choice=$(
"<li class='select2-search-choice'>" +
" <div></div>" +
- " <a href='#' onclick='return false;' class='select2-search-choice-close' tabindex='-1'></a>" +
+ " <a href='#' class='select2-search-choice-close' tabindex='-1'></a>" +
"</li>"),
id = this.id(data),
val = this.getVal(),
Something went wrong with that request. Please try again.