UNPKG

ractive-ez-combobox

Version:
29 lines (22 loc) 898 B
import Ractive from 'ractive'; import EzTabs from '../index.js'; import countries from './countries.json'; // https://pastebin.com/k79mKHzG import '../themes/blue.less'; countries.sort((a, b) => a.country_code > b.country_code); const contains = (value, text) => value.toLowerCase().indexOf(text.toLowerCase()) != -1; window.onload = function() { var instance = new Ractive({ el: document.querySelector("#container"), template: document.querySelector("#template").innerHTML, data() { return { value: null, values: [], items: countries, compare: (a, b) => a && b && a.country_code == b.country_code, filterAnywhere: (text, value) => contains(value, text), searchAsync: (text, callback) => setTimeout(() => callback(null, countries.filter(item => contains(item.country_name, text)).slice(0, 20)), 500) } } }); };