Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Remove inline onclick handlers #417

wants to merge 1 commit into from

3 participants


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:".


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.


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


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


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.


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.



@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.


closing until a viable solution is found.

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

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
6 select2.js
@@ -1389,7 +1389,7 @@
var container = $("<div></div>", {
"class": "select2-container"
- " <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>" ,
@@ -1488,7 +1488,7 @@
+ this.selection.bind("click", killEvent)"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>" +
id =,
val = this.getVal(),
Something went wrong with that request. Please try again.