From e935be761abcdbcf89532f82ad54ddced200f7db Mon Sep 17 00:00:00 2001 From: boni Date: Thu, 25 Feb 2016 13:14:45 +0100 Subject: [PATCH] fixing disappearing input value --- src/ajax-chosen.coffee | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/ajax-chosen.coffee b/src/ajax-chosen.coffee index 74a4fb6..0bd9a55 100644 --- a/src/ajax-chosen.coffee +++ b/src/ajax-chosen.coffee @@ -149,6 +149,7 @@ do ($ = jQuery) -> # searches impossible), so we add the value the user was typing back into # the input field. field.val(untrimmed_val) + field.data('ajaxChosenValue', untrimmed_val) # Because non-ajax Chosen isn't constantly re-building results, when it # DOES rebuild results (during liszt:updated above, it clears the input @@ -167,3 +168,6 @@ do ($ = jQuery) -> chosenXhr.abort() if chosenXhr chosenXhr = $.ajax(options) , options.afterTypeDelay + .bind 'ajaxStop', (data) -> + $field = $(data.currentTarget) + $field.val($field.data('ajaxChosenValue'))