Skip to content

Instantly share code, notes, and snippets.

@isuke
Created September 20, 2016 10:02
Show Gist options
  • Select an option

  • Save isuke/80be71ead9aa55cb8f3807192e8a5b1c to your computer and use it in GitHub Desktop.

Select an option

Save isuke/80be71ead9aa55cb8f3807192e8a5b1c to your computer and use it in GitHub Desktop.
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')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment