Sha256: 057f2e368b8c9f77a696ba876bfd375f6a75dd47b02d41f8684d4ece32759d9b
Contents?: true
Size: 1.43 KB
Versions: 13
Compression:
Stored size: 1.43 KB
Contents
(function() { var variantTemplate = HandlebarsTemplates["variants/autocomplete"]; var formatVariantResult = function(variant) { return variantTemplate({ variant: variant }); }; $.fn.variantAutocomplete = function(searchOptions) { if (searchOptions == null) { searchOptions = {}; } this.select2({ placeholder: Spree.translations.variant_placeholder, minimumInputLength: 3, initSelection: function(element, callback) { Spree.ajax({ url: Spree.routes.variants_api + "/" + element.val(), success: callback }); }, ajax: { url: Spree.routes.variants_api, datatype: "json", quietMillis: 500, data: function(term, page) { var searchData = { q: { product_name_or_sku_cont: term }, }; return _.extend(searchData, searchOptions); }, results: function(data, page) { window.variants = data["variants"]; return { results: data["variants"] }; } }, formatResult: formatVariantResult, formatSelection: function(variant, container, escapeMarkup) { if (variant.options_text) { return Select2.util.escapeMarkup(variant.name + " (" + variant.options_text + ")"); } else { return Select2.util.escapeMarkup(variant.name); } } }); }; })();
Version data entries
13 entries across 13 versions & 1 rubygems