Skip to content

Instantly share code, notes, and snippets.

@vici0uz
Last active January 10, 2023 03:45
Show Gist options
  • Save vici0uz/4bc07b6f2b787c0d7f3e50e0526df6b7 to your computer and use it in GitHub Desktop.
Save vici0uz/4bc07b6f2b787c0d7f3e50e0526df6b7 to your computer and use it in GitHub Desktop.
Async QSelect in BlitzForm schema
<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