From c496f028015ec90312ab203d9e5bcfbc086accdd Mon Sep 17 00:00:00 2001 From: David Worth Date: Fri, 11 Oct 2013 10:02:28 -0400 Subject: [PATCH] add support for the `paste` event After a paste event, wait a short time (50ms for now) until the text is actually present in the text-box, then trigger `keyup` as if that text had just been typed. --- src/ajax-chosen.coffee | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/ajax-chosen.coffee b/src/ajax-chosen.coffee index 74a4fb6..9fb8819 100644 --- a/src/ajax-chosen.coffee +++ b/src/ajax-chosen.coffee @@ -26,6 +26,13 @@ do ($ = jQuery) -> # our ajax autocomplete code. $(@).next('.chzn-container') .find(".search-field > input, .chzn-search > input") + + .bind 'paste', -> + ajax_chosen = $(this) + paste_callback = -> + ajax_chosen.trigger('keyup') + setTimeout(paste_callback, 50) + .bind 'keyup', -> # This code will be executed every time the user types a letter # into the input form that chosen has created