Skip to content

Instantly share code, notes, and snippets.

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

  • Save isuke/0c2f7853391a55cc7e1ce9c960061ddb to your computer and use it in GitHub Desktop.

Select an option

Save isuke/0c2f7853391a55cc7e1ce9c960061ddb to your computer and use it in GitHub Desktop.
vue autoNumeric directive
Vue.directive 'numeric',
twoWay: true
bind: ->
$(@el)
.autoNumeric('init', aPad: false)
.on 'change', =>
@set $(@el).autoNumeric('get')
update: (value) ->
el = $(@el).autoNumeric('set', value)
el.trigger('change') if el?
unbind: ->
$(@el).autoNumeric('destroy')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment