• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

myclabs/jquery.confirm: [Unmaintained] Confirm dialogs for buttons and links usi ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

myclabs/jquery.confirm

开源软件地址:

https://github.com/myclabs/jquery.confirm

开源编程语言:

JavaScript 47.1%

开源软件介绍:

jquery.confirm

Confirm dialogs for buttons and links.

This library is not maintained. Looking for a maintainer, please open an issue

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

Or npm:

$ npm install myclabs.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, if set to false no button at all.
  • 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.
  • modalOptionsBackdrop: Backdrop option for modal.
  • modalOptionsKeyboard: Keyboard option for bootsrap modal.

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.




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
agarzola/jQueryAutocompletePlugin: Jörn Zaefferer’s (now deprecated) jQuery pl ...发布时间:2022-07-07
下一篇:
kossnocorp/jquery.turbolinks: 发布时间:2022-07-07
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap