Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

HTML

            
              <script type="text/x-template" id="multiselect-template">
  <select multiple="multiple" name="my-select[]">
    <slot></slot>
  </select>
</script>

<div id="app">
  <h3>Simple wrapping of jquery-multiselect</h3>
  <p>Example copied and modified from <a href="http://loudev.com/#usage">http://loudev.com/#usage</a>
  </p>
  <p>
    Current Selected: {{selected.join(", ")}}
    <button @click="clearSelected">Clear</button>
    <button @click="selectAll">Select All</button>
    <button @click="addOption">Add an option</button>
  </p>
  <multiselect v-model="selected">
    <option v-for="option in options" :value="option">{{option}}</option>
  </multiselect>
</div>
            
          
!

CSS

            
              # CSS from https://github.com/lou/multi-select/blob/master/css/multi-select.css


.ms-container{
  background: transparent url('https://github.com/lou/multi-select/blob/master/img/switch.png?raw=true') no-repeat 50% 50%;
  width: 370px;
}

.ms-container:after{
  content: ".";
  display: block;
  height: 0;
  line-height: 0;
  font-size: 0;
  clear: both;
  min-height: 0;
  visibility: hidden;
}

.ms-container .ms-selectable, .ms-container .ms-selection{
  background: #fff;
  color: #555555;
  float: left;
  width: 45%;
}
.ms-container .ms-selection{
  float: right;
}

.ms-container .ms-list{
  -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
  -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
  box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
  -webkit-transition: border linear 0.2s, box-shadow linear 0.2s;
  -moz-transition: border linear 0.2s, box-shadow linear 0.2s;
  -ms-transition: border linear 0.2s, box-shadow linear 0.2s;
  -o-transition: border linear 0.2s, box-shadow linear 0.2s;
  transition: border linear 0.2s, box-shadow linear 0.2s;
  border: 1px solid #ccc;
  -webkit-border-radius: 3px;
  -moz-border-radius: 3px;
  border-radius: 3px;
  position: relative;
  height: 200px;
  padding: 0;
  overflow-y: auto;
}

.ms-container .ms-list.ms-focus{
  border-color: rgba(82, 168, 236, 0.8);
  -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 0.6);
  -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 0.6);
  box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 0.6);
  outline: 0;
  outline: thin dotted \9;
}

.ms-container ul{
  margin: 0;
  list-style-type: none;
  padding: 0;
}

.ms-container .ms-optgroup-container{
  width: 100%;
}

.ms-container .ms-optgroup-label{
  margin: 0;
  padding: 5px 0px 0px 5px;
  cursor: pointer;
  color: #999;
}

.ms-container .ms-selectable li.ms-elem-selectable,
.ms-container .ms-selection li.ms-elem-selection{
  border-bottom: 1px #eee solid;
  padding: 2px 10px;
  color: #555;
  font-size: 14px;
}

.ms-container .ms-selectable li.ms-hover,
.ms-container .ms-selection li.ms-hover{
  cursor: pointer;
  color: #fff;
  text-decoration: none;
  background-color: #08c;
}

.ms-container .ms-selectable li.disabled,
.ms-container .ms-selection li.disabled{
  background-color: #eee;
  color: #aaa;
  cursor: text;
}
            
          
!

JS

            
              const multiselectComponent = {
  template: '#multiselect-template',
  props: {
    value: Array,
    default: [],
  },
  watch: {
    value(newValue, oldValue) {
      if (JSON.stringify(newValue) !== JSON.stringify(oldValue)) {
        $(this.$el).multiSelect('deselect_all');
        $(this.$el).multiSelect('select', this.value);
      }
    }
  },
  updated() {
    $(this.$el).multiSelect('refresh');
  },
  mounted() { 
    $(this.$el).multiSelect({
      afterSelect: (values) => this.$emit('input', [...new Set(this.value.concat(values))]),
      afterDeselect: (values) => this.$emit('input', this.value.filter(x => !values.includes(x))),
    });
    $(this.$el).multiSelect('select', this.value);
  }

}

Vue.component('multiselect', multiselectComponent)

var app = new Vue({
  el: '#app',
  data() {
    return {
      selected: ['elem_1'],
      options: ['elem_1', 'elem_2', 'elem_3', 'elem_4'],
    };
  },
  methods: {
    clearSelected() {
      this.selected = [];
    },
    selectAll() {
      this.selected = [...this.options];
    },
    addOption() {
      this.options.push(`elem_${this.options.length + 1}`);
    },
  }
})
            
          
!
999px

Console