Skip to content
This repository was archived by the owner on Jun 11, 2025. It is now read-only.

Multi Select Dropdown / Auto-Reset#6

Merged
lgavillet merged 1 commit intomasterfrom
lwe-multi-reset
Jun 30, 2016
Merged

Multi Select Dropdown / Auto-Reset#6
lgavillet merged 1 commit intomasterfrom
lwe-multi-reset

Conversation

@lwe
Copy link
Contributor

@lwe lwe commented Jun 28, 2016

This PR adds the glue JavaScript code to automatically initialize any <select> using the materializecss .materialize_select() method. In addition it adds logic on top to correctly select / deselect items, for when a "reset" is required with in a situation like the following:

<select multiple data-mtl-select="multiple">
  <option value="">All items</option>
  <option value="1">First item</option>
  <option value="2">Second item</option>
</select>

So it properly selects / deselects the first element, but only when data-mtl-select="multiple" is used!

Demo

multi

Syntax

<!-- Default dropdown -->
<select data-mtl-select>
  <option>First</option>
  <option>Second</option>
</select>

<!-- With "reset-to-first" feature -->
<select multiple data-mtl-select="multiple">
  <option value="">All</option> <!-- value MUST BE "" -->
  <option>First</option>
  <option>Second</option>
</select>

@lwe lwe added the feature label Jun 28, 2016
@lwe lwe self-assigned this Jun 28, 2016
@lwe lwe force-pushed the lwe-multi-reset branch from 4514287 to 739c17f Compare June 28, 2016 15:11
@lwe
Copy link
Contributor Author

lwe commented Jun 28, 2016

/cc @sled and @JorisM, might be useful for you too

@lwe lwe force-pushed the lwe-multi-reset branch 2 times, most recently from 3ac59ae to 8aed041 Compare June 30, 2016 16:11
This adds support for the special handling of <select multiple>, but
requires a trigger via data-mtl-select, otherwise the `material_select()`
method is not called.

Other changes:
- Added MTL.onReady/onTurbolinksLoad
- Change hooks.coffee to use these
- Renamed data-mtl-nav="side"
@lwe lwe force-pushed the lwe-multi-reset branch from 8aed041 to d196fc0 Compare June 30, 2016 16:13
@lgavillet lgavillet merged commit 7d6b85e into master Jun 30, 2016
@lgavillet lgavillet deleted the lwe-multi-reset branch June 30, 2016 16:49
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants