Sha256: 48d34afac01de1671d2fbefdcec38bff402391ed3ccd76bbedc77f07a8feed1f
Contents?: true
Size: 1.14 KB
Versions: 2
Compression:
Stored size: 1.14 KB
Contents
$.fn.productAutocomplete = function (options) { 'use strict'; // Default options options = options || {}; var multiple = typeof(options.multiple) !== 'undefined' ? options.multiple : true; this.select2({ minimumInputLength: 3, multiple: multiple, initSelection: function (element, callback) { $.get(Spree.routes.product_search, { ids: element.val().split(',') }, function (data) { callback(multiple ? data.products : data.products[0]); }); }, ajax: { url: Spree.routes.product_search, datatype: 'json', data: function (term, page) { return { q: { name_cont: term, sku_cont: term }, m: 'OR' }; }, results: function (data, page) { var products = data.products ? data.products : []; return { results: products }; } }, formatResult: function (product) { return product.name; }, formatSelection: function (product) { return product.name; } }); }; $(document).ready(function () { $('.product_picker').productAutocomplete(); });
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
spree_backend-3.0.0.rc3 | app/assets/javascripts/spree/backend/product_picker.js |
spree_backend-3.0.0.rc1 | app/assets/javascripts/spree/backend/product_picker.js |