Sha256: cb3eaf16d6e609c59e599524c75c12fda51da4a20c169b8e4bee32b2d84cd439
Contents?: true
Size: 1.24 KB
Versions: 6
Compression:
Stored size: 1.24 KB
Contents
# variant autocompletion $(document).ready -> if $("#variant_autocomplete_template").length > 0 window.variantTemplate = Handlebars.compile($("#variant_autocomplete_template").text()) window.variantStockTemplate = Handlebars.compile($("#variant_autocomplete_stock_template").text()) return formatVariantResult = (variant) -> variant.image = variant.images[0].mini_url if variant["images"][0] isnt `undefined` and variant["images"][0].mini_url isnt `undefined` variantTemplate variant: variant $.fn.variantAutocomplete = -> @select2 placeholder: Spree.translations.variant_placeholder minimumInputLength: 3 initSelection: (element, callback) -> $.get Spree.routes.variants_search + "/" + element.val(), {}, (data) -> callback data ajax: url: Spree.url(Spree.routes.variants_api) datatype: "json" data: (term, page) -> q: product_name_or_sku_cont: term token: Spree.api_key results: (data, page) -> window.variants = data["variants"] results: data["variants"] formatResult: formatVariantResult formatSelection: (variant) -> if !!variant.options_text variant.name + " (#{variant.options_text})" else variant.name
Version data entries
6 entries across 6 versions & 1 rubygems