http://jsfiddle.net/jwogamhw/26/
function matchStart (term, text,element) { return (element.search.toUpperCase().indexOf(term.toUpperCase()) !== -1); } $("#hdn").select2.amd.require(['select2/compat/matcher'], function (oldMatcher) { $("#hdn").select2( { width: '300px', matcher: oldMatcher(matchStart), multiple: true, data: [ { id: 1, text: 'Italy', search: "bella Italia", children: [ { id: 2, text: 'Sardinia', search: "bella Italia Sardinia" }, { id: 3, text: 'Sicily', search: "bella Italia Sicily" } ] }, { id: 4, text: 'United Kingdom', search: "United Kingdom", children: [ { id: 5, text: 'Guernsey', search: "United Kingdom - Guernsey" }, { id: 6, text: 'Jersey', search: "United Kingdom - Jersey" } ] } ] }) .on("select2:select", function (e) { console.log("select2:select", e); }); });
Chciałbym go połączyć z tym skryptem, próbuje w ten sposob ale za nic nie chce dzialac.
Jest ktoś w stanie mi pomoc/doardzić w jaki sposob powinienem to zrobic?
$( '#hdn' ).select2({ width: '100%', matcher: function matchStart (term, text,element) { return (element.search.toUpperCase().indexOf(term.toUpperCase()) !== -1); }, ajax: { url: "../inc/ajax/plik.php", dataType: 'json', delay: 250, data: function (params) { return { query: params.term // search term }; }, processResults: function (data) { return { results: data }; }, cache: true }, minimumInputLength: 1, });