Bargain23
Bargain23

Reputation: 1973

How can I use selectize in an input form in Vue

Suppose I have an input field: <input type="text" placeholder="Select Teams" /> and I should be able to select Support by clicking the input field.

enter image description here

and then

enter image description here

I learned that this is possible using selectize. How should I be able to incorporate it as a vue directive?

Upvotes: 0

Views: 923

Answers (1)

Ikbel
Ikbel

Reputation: 7851

Try this.

Vue.directive('selectize', function(el, binding){
  var options = binding.value || {}
  $(el).selectize(options)
})

Then use v-selectize directive where you want.

You can also add more options. For example:

<input v-selectize="{maxItems: 3}" type="text" placeholder="Select Teams" />

Upvotes: 3

Related Questions