npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ember-dropkick

v1.0.1

Published

An Ember CLI addon for creating beautiful, graceful, and painless custom dropdowns with DropKick.js

Downloads

56

Readme

Ember-dropkick Build Status Ember Observer Score

Installation

  • ember install:addon ember-dropkick

Usage

Ember Dropkick extends Emberx-select. What this addon does is add "Dropkick sugar" to Emberx-select. Here are the Emberx-select docs slightly edited for DropKick:

By allowing arbitrary html to appear in the template of the select element, you can use it just like you would normally. This means things like having <optgroup> tags inside your select, or even plain old <option> elements to represent things like empty values.

XSelect thinly wraps a native <select> element so that it can be object and binding aware. It is used in conjuction with the dk-option component to construct select boxes. E.g.

{{#dk-select value=bob action="selectPerson"}}
  {{#dk-option value=fred}}Fred Flintstone{{/dk-option}}
  {{#dk-option value=bob}}Bob Newhart{{/dk-option}}
{{/dejk-select}}

the options are always up to date, so that when the object bound to value changes, the corresponding option becomes selected.

Whenever the select tag receives a change event, it will fire action.

If you're just changing a model's property, you don't need action. For example, if you have a model with a status field with an integer, you can do this:

{{#dk-select value=model.status }}
  {{#dk-option value=1}}Active{{/dk-option}}
  {{#dk-option value=2}}Inactive{{/dk-option}}
{{/dk-select}}

Multiselect

Ember-dropkick supports the multiple option. This means you can pass an array as its value, and it will set its selections directly on that array.

{{#dk-select value=selections multiple=true action="selectionsChanged"}}
 {{#dk-option value=fred}}Fred Flintstone{{/dk-option}}
 {{#dk-option value=bob}}Bob Newhart{{/dk-option}}
 {{#dk-option value=andrew}}Andrew WK{{/dk-option}}
{{/dk-select}}

The selections array will be initialized to an empty array if not present.

Action and Action Arguments

The action that is dispatched by dk-select whenever the selected value or values change has a function signature of:

/**
* @param value {Object} the value selected by the user.
* @param component {Ember.Component} the dk-select component itself
*/
function (value, component) {
  // action body...
}

Most of the time all you need is the value that has been selected, but sometimes your action requires more context than just that. In those cases, you can associate arbitrary attributes with the component itself and use them later inside your action handler. For example:

{{#dk-select action="didMakeSelection" default=anything}}
  <option>Nothing</option>
  {{#dk-option value=something}}Something{{/dk-option}}
{{/dk-select}}

then, inside your action handler:

export default Ember.Route.extend({
  actions: {
    didMakeSelection: function(selection, component) {
      if (selection) {
        this.set('selection', selection)
      } else {
        this.set('selection', component.get('default'))
      }
    }
  }
});

Passing DropKick options

In your controller:

export default Ember.Controller.extend({
  settings: {
    mobile: true
    .... (dk settings)
  }
});

In your template:

{{#dk-select action="didMakeSelection" default=anything settings=settings}}
  {{#dk-option value="nothing"}}Nothing{{/dk-option}}
  {{#dk-option value="something"}}Something{{/dk-option}}
{{/dk-select}}

You can see all of the options you can pass DropKick here.

Accessing the DropKick object

In some method somewhere:

Dropkick("#your_select_id").select(0) (or what ever method you chose).

We can do this because DropKick caches the objects it creates.