<script>
  init({
    title: 'Max Height Unit',
    desc: 'Use <code>maxHeightUnit: \'row\'</code> option to set the max height unit.',
    links: ['multiple-select.min.css'],
    scripts: ['multiple-select.min.js']
  })
</script>

<style>
select {
  width: 100%;
}
</style>

<div>
  <div class="form-group row">
    <label class="col-sm-2">
      Max Rows
    </label>

    <div class="col-sm-10">
      <input id="number" type="number" value="5" min="1" max="10">
    </div>
  </div>

  <div class="form-group row">
    <label class="col-sm-2">
      Single Select
    </label>

    <div class="col-sm-10">
      <select>
        <option value="1">January</option>
        <option value="2">February</option>
        <option value="3">March</option>
        <option value="4">April</option>
        <option value="5">May</option>
        <option value="6">June</option>
        <option value="7">July</option>
        <option value="8">August</option>
        <option value="9">September</option>
        <option value="10">October</option>
        <option value="11">November</option>
        <option value="12">December</option>
      </select>
    </div>
  </div>

  <div class="form-group row">
    <label class="col-sm-2">
      Multiple Select
    </label>

    <div class="col-sm-10">
      <select multiple="multiple">
        <option value="1">January</option>
        <option value="2">February</option>
        <option value="3">March</option>
        <option value="4">April</option>
        <option value="5">May</option>
        <option value="6">June</option>
        <option value="7">July</option>
        <option value="8">August</option>
        <option value="9">September</option>
        <option value="10">October</option>
        <option value="11">November</option>
        <option value="12">December</option>
      </select>
    </div>
  </div>
</div>

<script>
  function mounted() {
    $('select').multipleSelect({
      maxHeight: +$('#number').val(),
      maxHeightUnit: 'row'
    })

    $('#number').change(function () {
      $('select').multipleSelect('refreshOptions', {
        maxHeight: +$('#number').val(),
        maxHeightUnit: 'row'
      })
    })
  }
</script>
