Subscriptions


') checkSelect2Initialised() } function checkSelect2Initialised() { try { initiateSelect2() } catch(err) { setTimeout(checkSelect2Initialised,2000) } } function initiateSelect2() { jQuery(".appstle_product-search-select").each(function(index, selectEl) { var lastSearchTerm = ""; var next = false; var cursor = null; jQuery(selectEl).select2({ ajax: { url: "https://subscription-admin.appstle.com/api/data/products", dataType: 'json', delay: 250, data: function (params) { if (params.term !== lastSearchTerm) { next = false; cursor = null; } lastSearchTerm = params.term; return { search: params.term, // search term cursor: cursor, next: next, shop: shopName }; }, "async": true, "crossDomain": true, "headers": { "cache-control": "no-cache", "postman-token": "06eaf057-9152-2ff9-616b-c8f3f319e47f" }, processResults: function (data, params) { next = data.pageInfo.hasNextPage; cursor = data.pageInfo.cursor; return { results: data.products, pagination: { more: data.pageInfo.hasNextPage } }; }, cache: true }, minimumInputLength: 0, templateResult: formatRepo, templateSelection: formatRepoSelection }); }) } function formatRepo (product) { var container = jQuery( "

" + "
" + "
" + "
" ); container.find(".select2-result-repository__title").text(product.title); return container; } function formatRepoSelection (product) { return product.title; } // ]]>