Comments (5)
The Modal constructor indeed takes a Vue component object and NOT an instance. The reason is simple: it wraps the given template with required HTML markup so you won't have to.
An instantiated VM would have to already contain the markup. But let's think for a moment: we wanna be able to pass instantiated VM so we can also pass data, right? But we can already do that. If we want to be able to access data scope for our Modal, just pass a Javascript reference when creating Modal:
var someData = {
progress: 5,
list: [....]
}
let modal = Modal.create({
data: {
someData
},
template: '...'
})
// don't destroy it when we close it,
// so we can show it up again when we want to
modal.set({selfDestroy: false})
modal.show()
someData.progress = 7
modal.close()
modal.show()
modal.close()
someData.progress = 10
// ....or even
modal.vm.someData.progress = 10
modal.show()
....
modal.close()
/// finally when we don't need it anymore:
modal.destroy()
It's easier to write a *.vue component file and use it to create your Modal:
import { Modal } from 'quasar'
import LoginScreen from './login.vue'
Modal.create(LoginScreen)
Ok, so we've seen we can skip accessing data through events, vuex etc, but Vue best practices dictates that it's best to anyway use Vuex due to its many advantages.
Next Quasar (v0.6.0 -- skipping 0.5.1 due to its many novelties) will also make Modal be able to use a VM object containing an element, so you can use an existing template in DOM.
Given said that, is there still a case you wanna use and can't with current Modal?
from quasar.
Updated the documentation too to make it more clear. Will update website in a few hours.
from quasar.
Yes, you're right, we can just set data to the vm object backed by this Modal once it is instanciated. We loose the features of props (data validation, types, ...) but in my current case current case, the way you describe fits my needs. I think there is more advanced cases where passing a VM instance could be useful
from quasar.
Well, the validation can still be done through VM object. Even if set from "outside" of it. Add a watcher for your VM data prop on the VM object and validate it there, for example.
from quasar.
Will make a thorough analysis on how Modal management can be improved though. Thanks for opening this issue!
from quasar.
Related Issues (20)
- Wrong link in rules full list
- How to use `Dialog Plugin` to implement asynchronous commit operations? HOT 2
- How to use `Dialog Plugin` to implement asynchronous commit operations? HOT 2
- Flickering screen when resizing window
- bex build broken due to 'Could not resolve "quasar/src/utils/uid"' HOT 6
- @quasar/app-vite relies on vulnerable package html-minifier HOT 4
- unplugin-auto-import no longer working HOT 1
- Quasar CLI fails to open Android Studio from WSL Environment HOT 2
- q-tooltip component is actually using wrong font-size style. HOT 1
- Quasar build fails with latest cordova-ios HOT 7
- Chat-Message does not render buttons
- Quasar Not Starting After Installation Of Apollo AE HOT 4
- Missing Labels for QTable Pagination Buttons
- Problems with using Q-table Component
- Q-img high Recalc per sec when the image hasn't been in the viewport HOT 2
- q-editor - paragraph-tag property has no effect
- Quasar Electron can't build with Electron Builder versions 24.13.1 and higher (the default that Quasar pulls) using pnpm
- QInput `shadow-text` is showing when input is out of focus but `hasError` is true
- npm install error: node-waf: command not found (due to zlib dependency) HOT 1
- QEditor - Plaintext pasting example editorRef.value.runCmd() - Not found HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from quasar.