spree/spree — Issue #1026: product_autocomplete can not be included twice on a page
Author: cmar
Created: 2012-01-25 21:09:10+00:00
State: open

The implementation of product_autocomplete is dependent on #add_product_name and #add_variant_id. It could be improved by making the elements relative to the element that you attach product_autocomplete().

In promotions, you can have multiple actions for adding line items. Each one of these uses product_autocomplete. It works for the first one because it has the id #add_product_name. But the 2nd one has the same id and includes another element with #add_variant_id

$("#add_product_name").product_autocomplete();

I suspect most people only add one line_item action. We should either enforce single line_item actions or fix the product_autocomplete.

product_autocomplete is used in 2 locations. Orders (edit.js) and Promotions (promotions.js)