Commits

Maciej Wiśniowski committed 4e7016a

handle immediate submit of Product Management form when autocomplete is used

Comments (0)

Files changed (1)

lfs/static/js/lfs.manage.product.js

     };
 
     $('#id_manufacturer_autocomplete').autocomplete(MANUFACTURER_AUTOCOMPLETE_SETTINGS);
+    $('body').bind('form-save-start', function(evt){
+        if (evt.form_id == 'product-data-form'){
+            // ensure that manufacturer_id is cleared if autocomplete field is empty
+            if ($('#id_manufacturer_autocomplete').val() === ''){
+                $('#id_manufacturer').val('');
+            }
+        }
+    });
+
     // when form is reloaded we have to reattach autocomplete
     $('body').bind('form-save-end', function(evt){
         if (evt.form_id == 'product-data-form'){
             $('#id_manufacturer_autocomplete').autocomplete(MANUFACTURER_AUTOCOMPLETE_SETTINGS);
         }
-    })
+    });
 })