Giter Club home page Giter Club logo

vue-confirm-dialog's Introduction

issues npm npm version license

vue-confirm-dialog

Simple Confirm Dialog verification plugin with Vue.js.

Demo: https://aslanon.github.io/vue-confirm-dialog/

confirm-dialog

vue-confirm

Install

$ npm install --save vue-confirm-dialog

Quick Start Usage

In main.js or plugin (for Nuxt.js):

import Vue from 'vue'
import VueConfirmDialog from 'vue-confirm-dialog'

Vue.use(VueConfirmDialog)
Vue.component('vue-confirm-dialog', VueConfirmDialog.default)

In App.vue (or in the template file for Nuxt.js (layout/default.vue)):

<template>
  <div id="app">
    <vue-confirm-dialog></vue-confirm-dialog>
    <!-- your code -->
  </div>
</template>

<script>
  export default {
    name: 'app'
  }
</script>

In any of functions :

methods: {
    handleClick(){
      this.$confirm(
        {
          message: 'Are you sure?',
          button: {
            no: 'No',
            yes: 'Yes'
          },
          /**
          * Callback Function
          * @param {Boolean} confirm
          */
          callback: confirm => {
            if (confirm) {
              // ... do something
            }
          }
        }
      )
    }
  }

If you want to use in *.js file (e.g Vuex Store) before import Vue and after use Vue.$confirm.

import Vue from 'vue'

export default {
  namespaced: true,
  state: {},
  actions: {
    logout({ commit }) {
      Vue.$confirm({
        title: 'Are you sure?',
        message: 'Are you sure you want to logout?',
        button: {
          yes: 'Yes',
          no: 'Cancel'
        },
        callback: confirm => {
          // ...do something
        }
      })
    }
  }
}

API

If you want to password confirm, "auth" key is must be true.

this.$confirm({
  auth: true,
  message: 'foo',
  button: {
    yes: 'Yes',
    no: 'Cancel'
  },
  /**
   * Callback Function
   * @param {Boolean} confirm
   * @param {String} password
   */
  callback: (confirm, password) => {
    if (confirm && password == YOUR_PASSWORD) {
      // ...do something
    }
  }
})

Use only for information

If you want to use only for information and you want of see one button in dialog, you can use only one of 'no' or 'yes' button object.

vue-confirm

methods: {
    handleClick(){
      this.$confirm(
        {
          title: 'Information',
          message: 'This content has been removed',
          button: {
          	yes: 'OK',
          }
        },
        /**
        * Callback Function
        * @param {Boolean} confirm
        */
        callback: confirm => {
          if (confirm) {
            // ... do something
          }
        }
      )
    }
  }

vue-confirm-dialog's People

Contributors

aslanon avatar atillapehlivan avatar dependabot[bot] avatar ducz01 avatar yetem avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

vue-confirm-dialog's Issues

[Vue warn]: Unknown custom element: <vue-confirm-dialog> - did you register the component correctly?

Describe the bug
I have followed all the steps mentioned here but still, I am getting

[Vue warn]: Unknown custom element: - did you register the component correctly? For recursive components, make sure to provide the "name" option. found in ---> <Resources/nuxt/layouts/dashboard.vue> at resources/nuxt/layouts/dashboard.vue
**

File inside plugin
image

nuxt.config.js
image

layout/dashboard.vue
<client-only> <vue-confirm-dialog /> </client-only>

Allow click on overlay to exit without running callback assuming false

Is your feature request related to a problem? Please describe.
I would like to use this component more as a 2 option dialog (rather than a yes/no). Currently, if you click on the overlay then it behaves as "false" and runs the callback w/ false.

Describe the solution you'd like
I'd like clicking on the overlay to simply close the entire component without actually making a "no" selection.

Describe alternatives you've considered
The simplest solution would be to remove the callback on line 103, inside the method handleClickOverlay(). Or a more dynamic solution would be to allow you to define a separate onCancelCallback() to be used at init.

Additional context
Thanks for considering this. Making this change would allow for backwards compatibility while providing a huge improvement in a small area.

Nuxt 2.15.7 vue-confirm-dialog not found

ERROR Failed to compile with 1 errors friendly-errors 21:46:41

This dependency was not found:

  • vue-confirm-dialog in ./plugins/vue_confirm_dialog.client.js

1.1.0 version of vue-confirm-dialog.

I tried everything.

Yay! You broke it..

Latest version isn't usable at all... Installed, in node_modules, all looks good and dandy, buuuut no.

This dependency was not found:

* vue-confirm-dialog in ./src/main.js

To install it, you can run: npm install --save vue-confirm-dialog

Is it ready for Nuxt?

Added as plugin for Nuxt, got the following error: "document is not defined" in the following line:

var styleElement = document.querySelector('style[data-vue-ssr-id~="' + obj.id + '"]')

Seems like it doesn't work properly in SSR process.

can i change the color of the button? as well as the the dialog box color?

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Vue 3 Support

I'm upgrading a project form Vue 2 to Vue 3 at the moment and wondered if there was any possibility of upcoming Vue 3 support for this repo?

Thanks in advance for getting back!

Modal is not closing itself after click

Describe the bug
Modal is not closing

To Reproduce
Method in my Vue component I call:

deleteConfirm() {
  this.$confirm({
    auth: true,
    message: 'foo',
    button: {
      yes: 'Yes',
      no: 'Cancel'
    },
    callback: (confirm, password) => {
      if (confirm && password === 'danger') {
        console.log('BOOOOM!');
      } else {
        console.log('relax');
      }
    }
  });
}

Expected behavior
After clicking on Cancel or Yes I expect the modal to close.

Additional context
When clicking outside the modal-messagebox (the modal-layer with background-color) the modal gets
more and more transparent - so after maaany clicks its unvisible but I thought it should close itself
directly after a button click.
The console.log spits out the clicks correctly.

Dialog title does not change.

Describe the bug
If title has not been sent from the option json, it comes to default text

{
  "message": "Are you sure?",
  "auth": false,
  "button": {
    "yes": "OK"
  }
}

Have to click on 'Yes' button twice to close the dialog

I'm not sure how you can reproduce this bug but what it looks like to me is it seems like there are two overlays when the dialog appears. When I click on 'Yes' once, the background gets a bit lighter in transparency so I'm thinking this is when the first overlay is removed. Then I click on 'Yes' again because the dialog is still present. And only then the dialog closes.

Update
It's not only for the Yes button, but the No button as well.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.