question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Call a method open() on the component <mdl-dialog> by clicking on <mdl-button>

See original GitHub issue

I 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:closed
  • Created 7 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
posvacommented, Dec 28, 2016
  export default {
    name: 'index',
    data () {
      return {
        slogan: 'text',
        subSlogan: 'text'
      }
    },
    methods: {
      open () {
        this.$refs.register.open()
      }
    }
  }

then in button:

<button @click="open">...</button>
0reactions
LANSELOTcommented, Dec 29, 2016

It works, thanks)

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found