Skip to content

Commit

Permalink
Properly clean-up deselected trigger when updating field. (Closes har…
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick Filler committed May 3, 2012
1 parent 683efa7 commit 9c5ecab
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 10 deletions.
5 changes: 3 additions & 2 deletions chosen/chosen.jquery.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ Copyright (c) 2011 by Harvest
};

AbstractChosen.prototype.results_update_field = function() {
this.results_reset();
this.result_clear_highlight();
this.result_single_selected = null;
return this.results_build();
Expand Down Expand Up @@ -692,12 +693,12 @@ Copyright (c) 2011 by Harvest
return link.parents('li').first().remove();
};

Chosen.prototype.results_reset = function(evt) {
Chosen.prototype.results_reset = function() {
this.form_field.options[0].selected = true;
this.selected_item.find("span").text(this.default_text);
if (!this.is_multiple) this.selected_item.addClass("chzn-default");
this.show_search_field_default();
$(evt.target).remove();
this.selected_item.find("abbr").remove();
this.form_field_jq.trigger("change");
if (this.active_field) return this.results_hide();
};
Expand Down
2 changes: 1 addition & 1 deletion chosen/chosen.jquery.min.js

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions chosen/chosen.proto.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ Copyright (c) 2011 by Harvest
};

AbstractChosen.prototype.results_update_field = function() {
this.results_reset();
this.result_clear_highlight();
this.result_single_selected = null;
return this.results_build();
Expand Down Expand Up @@ -684,12 +685,12 @@ Copyright (c) 2011 by Harvest
return link.up('li').remove();
};

Chosen.prototype.results_reset = function(evt) {
Chosen.prototype.results_reset = function() {
this.form_field.options[0].selected = true;
this.selected_item.down("span").update(this.default_text);
if (!this.is_multiple) this.selected_item.addClassName("chzn-default");
this.show_search_field_default();
evt.target.remove();
this.selected_item.down("abbr").remove();
if (typeof Event.simulate === 'function') this.form_field.simulate("change");
if (this.active_field) return this.results_hide();
};
Expand Down
2 changes: 1 addition & 1 deletion chosen/chosen.proto.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions coffee/chosen.jquery.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -319,12 +319,12 @@ class Chosen extends AbstractChosen
this.result_deselect (link.attr "rel")
link.parents('li').first().remove()

results_reset: (evt) ->
results_reset: ->
@form_field.options[0].selected = true
@selected_item.find("span").text @default_text
@selected_item.addClass("chzn-default") if not @is_multiple
this.show_search_field_default()
$(evt.target).remove();
@selected_item.find("abbr").remove()
@form_field_jq.trigger "change"
this.results_hide() if @active_field

Expand Down
4 changes: 2 additions & 2 deletions coffee/chosen.proto.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -311,12 +311,12 @@ class Chosen extends AbstractChosen
this.result_deselect link.readAttribute("rel")
link.up('li').remove()

results_reset: (evt) ->
results_reset: ->
@form_field.options[0].selected = true
@selected_item.down("span").update(@default_text)
@selected_item.addClassName("chzn-default") if not @is_multiple
this.show_search_field_default()
evt.target.remove()
@selected_item.down("abbr").remove()
@form_field.simulate("change") if typeof Event.simulate is 'function'
this.results_hide() if @active_field

Expand Down
1 change: 1 addition & 0 deletions coffee/lib/abstract-chosen.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class AbstractChosen
""

results_update_field: ->
this.results_reset()
this.result_clear_highlight()
@result_single_selected = null
this.results_build()
Expand Down

0 comments on commit 9c5ecab

Please sign in to comment.