Last active
January 10, 2023 03:45
-
-
Save vici0uz/4bc07b6f2b787c0d7f3e50e0526df6b7 to your computer and use it in GitHub Desktop.
Async QSelect in BlitzForm schema
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<div class="q-pa-md"> | |
<q-btn @click="testNewOptions">TEST FILL SELECT</q-btn> | |
<blitz-form v-model="formData" :schema="schema" :columnCount="2" :mode="mode"/> | |
</div> | |
</template> | |
<script> | |
import { defineComponent, ref, onMounted } from 'vue'; | |
import { BlitzForm } from 'blitzar'; | |
import { QSelect, QInput } from 'quasar'; | |
export default defineComponent ({ | |
setup(props, context){ | |
const formData = ref(null); | |
const mode = ref('edit'); | |
const select_options_ref = ref([]); | |
const select_options_array = [{label: 'USA', value: 1}, {label: 'Canada', value: 2}]; | |
const domRef = ref(null); | |
function testNewOptions(){ | |
const selectRef = domRef.value[0].$refs['ref-component']; | |
select_options_ref = select_options_array; | |
selectRef.focus() // just to probe DOM ref is working | |
} | |
const schema = [ | |
// dummy field | |
{ | |
id: 'name', | |
component: 'QInput', | |
label: 'Name', | |
required: false, | |
}, | |
{ | |
id: 'country_id' | |
component: 'QSelect', | |
label: 'Country', | |
required: false, | |
dynamicProps ['options'], | |
'use-input': true, | |
style: "width: 250px", | |
ref: domRef, | |
events: {}, | |
options: () => select_options_ref.value, | |
} | |
] | |
return { | |
formData, | |
domRef, | |
schema, | |
testNewOptions, | |
mode | |
} | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment