isuke
9/20/2016 - 10:02 AM

vue select2 directice

vue select2 directice

$ ->
  Vue.directive 'select',
    twoWay: true
    priority: 1000

    params: ['options']

    bind: ->
      self = @
      $(@el)
        .select2()
        .on 'change', ->
          self.set(@value)
    update: ->
      $(@el).trigger('change')
      @update = (value) => $(@el).val(value).trigger('change')
    unbind: ->
      $(@el).off().select2('destroy')