Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Select item on <select> changed event
  • Loading branch information
zmack committed Sep 14, 2011
1 parent c338671 commit 37a17eb
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
19 changes: 17 additions & 2 deletions chosen/chosen.jquery.js
Expand Up @@ -163,7 +163,19 @@
return this.pending_destroy_click = false;
}
};
Chosen.prototype.select_changed = function(evt) {};
Chosen.prototype.select_changed = function(evt) {
if (!this.is_multiple) {
return this.select_item(this.form_field.selectedIndex);
}
};
Chosen.prototype.select_item = function(index) {
var id, item;
item = this.results_data[index + ''];
id = this.option_id_for_index(item.array_index);
this.selected_item.find("span").first().text(item.text);
this.container.find('li.result-selected').removeClass('result-selected');
return $("#" + id).addClass('result-selected');
};
Chosen.prototype.mouse_enter = function() {
return this.mouse_on_container = true;
};
Expand Down Expand Up @@ -260,10 +272,13 @@
return "";
}
};
Chosen.prototype.option_id_for_index = function(index) {
return this.container_id() + "_o_" + index;
};
Chosen.prototype.result_add_option = function(option) {
var classes;
if (!option.disabled) {
option.dom_id = this.container_id() + "_o_" + option.array_index;
option.dom_id = this.option_id_for_index(option.array_index);
classes = option.selected && this.is_multiple ? [] : ["active-result"];
if (option.selected) {
classes.push("result-selected");
Expand Down

0 comments on commit 37a17eb

Please sign in to comment.