Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"chosen:close" triggerable event #1663

Merged
merged 3 commits into from
Nov 21, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions coffee/chosen.jquery.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class Chosen extends AbstractChosen
else
@search_container = @container.find('div.chosen-search').first()
@selected_item = @container.find('.chosen-single').first()

this.results_build()
this.set_tab_index()
this.set_label_behavior()
Expand All @@ -83,6 +83,7 @@ class Chosen extends AbstractChosen
@form_field_jq.bind "chosen:updated.chosen", (evt) => this.results_update_field(evt); return
@form_field_jq.bind "chosen:activate.chosen", (evt) => this.activate_field(evt); return
@form_field_jq.bind "chosen:open.chosen", (evt) => this.container_mousedown(evt); return
@form_field_jq.bind "chosen:close.chosen", (evt) => this.input_blur(evt); return

@search_field.bind 'blur.chosen', (evt) => this.input_blur(evt); return
@search_field.bind 'keyup.chosen', (evt) => this.keyup_checker(evt); return
Expand Down Expand Up @@ -291,7 +292,7 @@ class Chosen extends AbstractChosen
close_link = $('<a />', { class: 'search-choice-close', 'data-option-array-index': item.array_index })
close_link.bind 'click.chosen', (evt) => this.choice_destroy_link_click(evt)
choice.append close_link

@search_container.before choice

choice_destroy_link_click: (evt) ->
Expand Down
5 changes: 3 additions & 2 deletions coffee/chosen.proto.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ class @Chosen extends AbstractChosen
@form_field.observe "chosen:updated", (evt) => this.results_update_field(evt)
@form_field.observe "chosen:activate", (evt) => this.activate_field(evt)
@form_field.observe "chosen:open", (evt) => this.container_mousedown(evt)
@form_field.observe "chosen:close", (evt) => this.input_blur(evt)

@search_field.observe "blur", (evt) => this.input_blur(evt)
@search_field.observe "keyup", (evt) => this.keyup_checker(evt)
Expand All @@ -92,7 +93,7 @@ class @Chosen extends AbstractChosen
@container.select(".search-choice-close").each (choice) ->
choice.stopObserving()
else
@selected_item.stopObserving()
@selected_item.stopObserving()

if @search_field.tabIndex
@form_field.tabIndex = @search_field.tabIndex
Expand Down Expand Up @@ -330,7 +331,7 @@ class @Chosen extends AbstractChosen
high.removeClassName("active-result")
else
this.reset_single_select_options()

high.addClassName("result-selected")

item = @results_data[ high.getAttribute("data-option-array-index") ]
Expand Down
6 changes: 5 additions & 1 deletion public/options.html
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ <h3>Example:</h3>
<tr>
<td>no_results_text</td>
<td>"No results match"</td>
<td>The text to be displayed when no matching results are found. The current search is shown at the end of the text (e.g.
<td>The text to be displayed when no matching results are found. The current search is shown at the end of the text (e.g.
No reults match "Bad Search").</td>
</tr>
<tr>
Expand Down Expand Up @@ -238,6 +238,10 @@ <h3>Example:</h3>
<td>chosen:open</td>
<td>This event activates Chosen and also displays the search results.</td>
</tr>
<tr>
<td>chosen:close</td>
<td>This event deactivates Chosen and hides the search results.</td>
</tr>
</table>

<footer>
Expand Down