Sha256: eea556eeb760e20d8786208fdcbef853fa2bfc25c578cd43e80afd53e8842ad3
Contents?: true
Size: 1.01 KB
Versions: 107
Compression:
Stored size: 1.01 KB
Contents
$.fn.alchemyNodeSelect = function (options) { var renderNodeTemplate = function (node) { return HandlebarsTemplates.node({ node: node }) } var queryParamsFromTerm = function (term) { return { filter: Object.assign( { name_or_page_name_cont: term }, options.query_params ) } } var resultsFromResponse = function (response) { var meta = response.meta var data = response.data var more = meta.page * meta.per_page < meta.total_count return { results: data, more: more } } return this.select2({ placeholder: options.placeholder, allowClear: true, minimumInputLength: 3, initSelection: function (_$el, callback) { if (options.initialSelection) { callback(options.initialSelection) } }, ajax: { url: options.url, datatype: "json", quietMillis: 300, data: queryParamsFromTerm, results: resultsFromResponse }, formatSelection: renderNodeTemplate, formatResult: renderNodeTemplate }) }
Version data entries
107 entries across 107 versions & 1 rubygems