Giter Site home page Giter Site logo

pablovidelayanez / jquery.confirm Goto Github PK

View Code? Open in Web Editor NEW

This project forked from myclabs/jquery.confirm

0.0 1.0 0.0 618 KB

Confirm dialogs for buttons and links using jQuery and Bootstrap

Home Page: http://myclabs.github.com/jquery.confirm/

jquery.confirm's Introduction

jquery.confirm

Confirm dialogs for buttons and links.

Chat room:

Requirements

If you use Bootstrap 2, you can use any 1.x version. From 2.0 and onwards, Bootstrap 3 is required.

Installation

The library can be downloaded manually or installed with Bower:

$ bower install jquery-confirm

Usage

<a href="home" class="confirm">Go to home</a>
$(".confirm").confirm();

Any click on the link will pop up a dialog asking the user to confirm the action.

Options

List of the options:

  • text: Text to display in the dialog
  • title: Title of the dialog (can be empty, the dialog will not have a header then)
  • confirm: Handler executed when the user confirms
  • cancel: Handler executed when the user cancels
  • confirmButton: Label of the confirm button
  • cancelButton: Label of the cancel button
  • post: If false (default) and no confirm handler is set, redirects the user to the URL of the button/link with a GET request. If true, redirects with a POST request (like a form submission).
  • confirmButtonClass: HTML class for the confirmation button, defaults to btn-primary.

Example:

<button class="confirm" type="button">Delete the comment</button>
$(".confirm").confirm({
    text: "Are you sure you want to delete that comment?",
    title: "Confirmation required",
    confirm: function(button) {
        delete();
    },
    cancel: function(button) {
        // nothing to do
    },
    confirmButton: "Yes I am",
    cancelButton: "No",
    post: true,
    confirmButtonClass: "btn-danger"
});

You can also use data- attributes to customize the confirmation dialog:

<button class="confirm" type="button"
        data-text="Do you really want to delete that comment?"
        data-confirm-button="Yes I am">
    Delete the user
</button>
$(".confirm").confirm();

Manual triggering

You can manually trigger the confirmation dialog:

// Will immediately show the confirmation popup
$.confirm({
    text: "Are you sure you want to delete that comment?",
    confirm: function() {
        delete();
    },
    cancel: function() {
        // nothing to do
    }
});

Remember that if you trigger the confirmation dialog manually, you must provide a confirm callback (as shown above).

Global configuration

You can configure some options globally, for example if you translate the messages:

$.confirm.options = {
    text: "Are you sure?",
    title: "",
    confirmButton: "Yes",
    cancelButton: "Cancel",
    post: false,
    confirmButtonClass: "btn-warning"
}

Contributing

Pull requests and bug reports are welcome! Be aware that you do not need to generate the minified version yourself, it will be generated by a release manager (for security reasons).

Change log

jquery.confirm's People

Contributors

mnapoli avatar marcusschwarz avatar mrjoelkemp avatar soulman-is-good avatar bnvk avatar dairyisscary avatar martinffx avatar

Watchers

Pablo Videla avatar

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.