Commits

Mark Lavin  committed a15b22c

Bind hidden inputs to select and change. Fixes #17.

  • Participants
  • Parent commits 3b971fa

Comments (0)

Files changed (1)

File selectable/static/js/jquery.dj.selectable.js

     $(":input[data-selectable-type=hidden]", context).each(function(i, elem) {
         var hiddenName = $(elem).attr('name');
         var textName = hiddenName.replace('_1', '_0');
-        $(":input[name=" + textName + "][data-selectable-url]").bind("autocompletechange", function(event, ui) {
-            if (ui.item && ui.item.id) {
-                $(elem).val(ui.item.id);
-            } else {
-                $(elem).val("");
+        $(":input[name=" + textName + "][data-selectable-url]").bind(
+            "autocompletechange autocompleteselect",
+            function(event, ui) {
+                if (ui.item && ui.item.id) {
+                    $(elem).val(ui.item.id);
+                } else {
+                    $(elem).val("");
+                }
             }
-        });
+        );
     });
 }