GithubHelp home page GithubHelp logo

pkdevboxy / jquery.confirm Goto Github PK

View Code? Open in Web Editor NEW

This project forked from myclabs/jquery.confirm

0.0 2.0 0.0 650 KB

Confirm dialogs for buttons and links using jQuery and Bootstrap

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

HTML 53.98% JavaScript 30.33% CSS 15.69%

jquery.confirm's Introduction

jquery.confirm

Confirm dialogs for buttons and links.

Average time to resolve an issue Percentage of issues still open

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).
  • submitForm: If false (default) it has no effect. If true, it submit the form target element.
  • confirmButtonClass: HTML class for the confirmation button, defaults to btn-primary.
  • cancelButtonClass: HTML class for the cancel button, defaults to btn-default.
  • dialogClass: HTML class for the dialog, defaults to modal-dialog.

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",
    cancelButtonClass: "btn-default",
    dialogClass: "modal-dialog modal-lg" // Bootstrap classes for large modal
});

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"
        data-cancel-button="Whoops no">
    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,
    submitForm: false,
    confirmButtonClass: "btn-warning",
    cancelButtonClass: "btn-default",
    dialogClass: "modal-dialog"
}

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

View the changelog.

License

This software is released under the MIT license.

jquery.confirm's People

Contributors

mnapoli avatar marcusschwarz avatar alemata avatar mrjoelkemp avatar yonmanbehalf avatar soulman-is-good avatar bnvk avatar dairyisscary avatar martinffx avatar omgimalexis avatar jdreesen avatar mhlavac avatar r-baker avatar

Watchers

James Cloos avatar Karthikeyan 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.