2
0
mirror of https://github.com/tenrok/vue-select.git synced 2026-06-01 05:54:03 +03:00

better dev template for ajax

This commit is contained in:
Jeff Sagal
2017-03-22 18:35:12 -07:00
parent bae486a8e3
commit 8a17aef811
2 changed files with 19 additions and 2 deletions
+1 -1
View File
@@ -35,7 +35,7 @@
<v-select placeholder="multiple, taggable" multiple taggable :options="options" no-drop></v-select>
<v-select placeholder="multiple, taggable, push-tags" multiple push-tags taggable :options="[{label: 'Foo', value: 'foo'}]"></v-select>
<v-select placeholder="unsearchable" :options="options" :searchable="false"></v-select>
<v-select placeholder="loading" loading></v-select>
<v-select placeholder="search github.." label="full_name" @search="search" :options="ajaxRes"></v-select>
</div>
</body>
+18 -1
View File
@@ -1,6 +1,10 @@
import Vue from 'vue'
import vSelect from './components/Select.vue'
import countries from 'docs/data/advanced.js'
import debounce from 'lodash/debounce'
import resource from 'vue-resource'
Vue.use(resource)
Vue.component('v-select', vSelect)
@@ -12,6 +16,19 @@ new Vue({
data: {
placeholder: "placeholder",
value: null,
options: countries
options: countries,
ajaxRes: []
},
methods: {
search(search, loading) {
loading(true)
this.getRepositories(search, loading, this)
},
getRepositories: debounce((search, loading, vm) => {
vm.$http.get(`https://api.github.com/search/repositories?q=${search}`).then(res => {
vm.ajaxRes = res.data.items
loading(false)
})
}, 250)
}
})