Call a method open() on the component <mdl-dialog> by clicking on <mdl-button>
See original GitHub issueI am use component of the dialog window dialog.vue or <mdl-dialog>
<template>
<div class="mdl-dialog-container" v-show="show">
<div class="mdl-dialog">
<div class="mdl-dialog__title">{{title}}</div>
<div class="mdl-dialog__content">
<slot></slot>
</div>
<div class="mdl-dialog__actions" :class="actionsClasses">
<slot name="actions">
<mdl-button class="mdl-js-ripple-effect" @click.native.stop="close">Close</mdl-button>
</slot>
</div>
</div>
</div>
</template>
<script>
import mdlButton from './button.vue'
import createFocusTrap from 'focus-trap'
export default {
components: {
mdlButton
},
computed: {
actionsClasses () {
return {
'mdl-dialog__actions--full-width': this.fullWidth
}
}
},
data () {
return {
show: false
}
},
props: {
title: {
type: String
},
fullWidth: Boolean
},
mounted () {
this._focusTrap = createFocusTrap(this.$el)
},
methods: {
open () {
this.show = true
this.$nextTick(() => this._focusTrap.activate())
this.$emit('open')
},
close () {
this.show = false
this._focusTrap.deactivate()
this.$emit('close')
}
}
}
</script>
I want to bring a dialog window to the other component
<mdl-dialog></mdl-dialog>
<button class="mdl-button mdl-js-button mdl-button--raised">Click me</button>
I found no information on how to call a method of one component within the other. All examples are mainly used props.
How can I call a method open() in <mdl-dialog></mdl-dialog>?
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Calling a function on Bootstrap modal open - Stack Overflow
I tried to use an onclick listener of the button, but the alert message was displayed before the modal appeared: $( ".code-dialog" ).click(function(){...
Read more >Bootstrap Modal - examples & tutorial
Modal is a responsive popup used to display extra content. That includes prompts, configurations, cookie consents, etc. Use MDB modal plugin to add...
Read more >Modal Dialog Example | APG | WAI - W3C
Following is an example implementation of the design pattern for modal dialogs. The below Add Delivery Address button opens a modal dialog ......
Read more >Dialog | Modal | JET Developer Cookbook - Oracle
Define buttons with actions within the footer: In this demo, clicking on the "OK" button will close the dialog. This is implemented by...
Read more >Modal Dialog Component | FREE Blazor Crash Course (.NET 5)
Create the Modal Dialog Component We right-click the Components folder and add a new Razor Component. In the new item dialog, we name...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

then in button:
It works, thanks)