Skip to content

Instantly share code, notes, and snippets.

@kriswill
Created May 10, 2012 18:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kriswill/2654826 to your computer and use it in GitHub Desktop.
Save kriswill/2654826 to your computer and use it in GitHub Desktop.
Chosen IE7 Prototype.js git-diff
diff --git a/chosen/chosen.proto.js b/chosen/chosen.proto.js
index e5049b0..0200299 100644
--- a/chosen/chosen.proto.js
+++ b/chosen/chosen.proto.js
@@ -408,14 +408,15 @@ Copyright (c) 2011 by Harvest
Chosen.prototype.container_mousedown = function(evt) {
var target_closelink;
if (!this.is_disabled) {
- target_closelink = evt != null ? evt.target.hasClassName("search-choice-close") : false;
+ var target = evt != null && evt.target ? $(evt.target) : null
+ target_closelink = target ? target.hasClassName("search-choice-close") : false;
if (evt && evt.type === "mousedown" && !this.results_showing) evt.stop();
if (!this.pending_destroy_click && !target_closelink) {
if (!this.active_field) {
if (this.is_multiple) this.search_field.clear();
document.observe("click", this.click_test_action);
this.results_show();
- } else if (!this.is_multiple && evt && (evt.target === this.selected_item || evt.target.up("a.chzn-single"))) {
+ } else if (!this.is_multiple && evt && (evt.target === this.selected_item || target.up("a.chzn-single"))) {
this.results_toggle();
}
return this.activate_field();
@@ -462,7 +463,8 @@ Copyright (c) 2011 by Harvest
};
Chosen.prototype.test_active_click = function(evt) {
- if (evt.target.up('#' + this.container_id)) {
+ var target = evt.target ? $(evt.target) : null;
+ if (target && target.up('#' + this.container_id)) {
return this.active_field = true;
} else {
return this.close_field();
@kriswill
Copy link
Author

IE7 doesn't allow prototype.js to modify the built-in types so this breaks in chosen.js.

We should make a pull request in coffeescript for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment