Sha256: 27da49bb754b95912673b78df3179a2afb96be27f844a8f220beaaee67e56422

Contents?: true

Size: 1.08 KB

Versions: 46

Compression:

Stored size: 1.08 KB

Contents

<%= pb_rails("typeahead", props: { async: true, load_options: 'asyncPillsPromiseOptions', label: "Github Users", name: :foo, pills: true, placeholder: "type the name of a Github user" }) %>

<!-- This section is an example of how to provide load_options prop for using dynamic options -->
<%= javascript_tag defer: "defer" do %>
  // Simple filter function, providing a list of results in the expected data format

  const filterResults = function(results) {
    return results.items.map(function(result) {
      return {
        label: result.login,
        value: result.id,
      }
    })
  }

  /* Note: Make sure you assign this to window or a namespace within window
  or it will not be accessible to the kit! */

  window.asyncPillsPromiseOptions = 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(filterResults(results))})
      } else {
        resolve([])
      }
    })
  }
<% end %>

Version data entries

46 entries across 46 versions & 1 rubygems

Version Path
playbook_ui-7.9.0 app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills_async.html.erb
playbook_ui-7.8.4 app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills_async.html.erb
playbook_ui-7.8.3 app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills_async.html.erb
playbook_ui-7.8.2 app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills_async.html.erb
playbook_ui-7.8.1 app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills_async.html.erb
playbook_ui-7.8.0 app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills_async.html.erb
playbook_ui-7.7.0.pre.alpha1 app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills_async.html.erb
playbook_ui-7.7.0 app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills_async.html.erb
playbook_ui-7.6.2.pre.alpha1 app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills_async.html.erb
playbook_ui-7.6.2 app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills_async.html.erb
playbook_ui-7.6.1.pre.alpha1 app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills_async.html.erb
playbook_ui-7.6.1 app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills_async.html.erb
playbook_ui-7.6.0 app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills_async.html.erb
playbook_ui-7.5.1 app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills_async.html.erb
playbook_ui-7.5.0 app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills_async.html.erb
playbook_ui-7.4.2 app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills_async.html.erb
playbook_ui-7.4.1 app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills_async.html.erb
playbook_ui-7.4.0.pre.alpha6 app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills_async.html.erb
playbook_ui-7.4.0.pre.alpha5 app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills_async.html.erb
playbook_ui-7.4.0 app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills_async.html.erb