Instance Methods

Data Changes

vm.$watch( keypath, callback )

Watch a keypath on the vm’s data object for changes and call the callback with the new value.

vm.$unwatch( keypath, [callback] )

Stop watching the given keypath. If a callback is given only that callback gets unwatched.

Cross-ViewModel Events

Each vm is also an event emitter. When you have multiple nested ViewModels, you can use the event system to communicate between them.

vm.$emit( event, [args…] )

Emit an event from the current vm that propagates all the way up to its $root.

vm.$broadcast( event, [args…] )

Emit an event to all children vms of the current vm, which gets further broadcasted to their children all the way down.

vm.$on( event, callback )

Listen for an event on the current vm.

vm.$off( [event, callback] )

If no arguments are given, stop listening for all events; If only the event is given, remove all callbacks for that event; If both event and callback are given, remove that specific callback only.

DOM Manipulation

All vm DOM manipulation methods work like their jQuery counterparts - except they also trigger vue.js transitions if there are any declared on vm’s $el. For more details on transitions see Using Transition Effects.

vm.$appendTo( element | selector )

Append the vm’s $el to target element. The argument can be either an element or a querySelector string.

vm.$before( element | selector )

Insert the vm’s $el before target element.

vm.$after( element | selector )

Insert the vm’s $el after target element.

vm.$remove()

Remove the vm’s $el from the DOM.

Misc

vm.$destroy()

Completely destroy a vm. Clean up its connections with other existing vms, unbind all its directives and remove its $el from the DOM.