Sha256: c41624b6de46969ee50ef924ddf4152538bfe812e561007a1b627050c8054e94
Contents?: true
Size: 859 Bytes
Versions: 54
Compression:
Stored size: 859 Bytes
Contents
<%= pb_rails("typeahead", props: { async: true, load_options: 'asyncPillsPromiseOptionsUsers', label: "Github Users", name: :foo, pills: true, placeholder: "type the name of a Github user" }) %> <%= javascript_tag defer: "defer" do %> const filterUserResults = function(results) { return results.items.map(function(result) { return { imageUrl: result.avatar_url, label: result.login, value: result.id, } }) } window.asyncPillsPromiseOptionsUsers = function(inputValue) { return new Promise(function(resolve) { if (inputValue) { fetch(`https://api.github.com/search/users?q=${inputValue}`) .then(function(response) { return response.json() }) .then(function(results) { resolve(filterUserResults(results))}) } else { resolve([]) } }) } <% end %>
Version data entries
54 entries across 54 versions & 1 rubygems