I modified the Wrapper Component Example from the VueJS documentation to include the AJAX datasource option. Here is my code.
However, I would like to set the ajax
url
property of my select2 component dynamically preferably like this,
<select2 :options="options" v-model="selected" url="dynamic-url-here">
<option disabled value="0">Select one</option>
</select2>
How would I do this?
Add the property:
Move the AJAX options either to a variable with scope outside the select2 component or a data element of that component:
use that variable when initializing the select2:
Add a watcher for url:
Set the property:
where
url
is defined in the data object of the app.See a demonstration in this plunker example.