zoukankan      html  css  js  c++  java
  • jquery-confirm使用方法

    简要教程
    jquery-confirm是一款功能强大的jQuery对话框和确认框插件。它提供多种内置的主题效果,可以实现ajax远程加载内容,提供动画效果和丰富的配置参数等。它的特点还有:

    可以使用键盘控制对话框。
    通过ajax加载对话框的内容。
    可以在指定时间之后自动关闭对话框。
    提供丰富的参数和回调函数。
    使用方法
    基本调用
    复制代码
    $.confirm({
    confirm: function(){
    console.log('the user clicked confirm');
    },
    cancel: function(){
    console.log('the user clicked cancel');
    }
    });
    复制代码

    全局默认参数
    复制代码
    jconfirm.defaults = {
    title: 'Hello',
    content: 'Are you sure to continue?',
    contentLoaded: function(){
    },
    icon: '',
    confirmButton: 'Okay',
    cancelButton: 'Close',
    confirmButtonClass: 'btn-default',
    cancelButtonClass: 'btn-default',
    theme: 'white',
    animation: 'zoom',
    closeAnimation: 'scale',
    animationSpeed: 500,
    animationBounce: 1.2,
    keyboardEnabled: false,
    rtl: false,
    confirmKeys: [13], // ENTER key
    cancelKeys: [27], // ESC key
    container: 'body',
    confirm: function () {
    },
    cancel: function () {
    },
    backgroundDismiss: false,
    autoClose: false,
    closeIcon: null,
    columnClass: 'col-md-4 col-md-offset-4 col-sm-6 col-sm-offset-3 col-xs-10 col-xs-offset-1',
    onOpen: function(){
    },
    onClose: function(){
    },
    onAction: function(){
    }
    };

    API
    复制代码
    通过var jc = $.confirm()会返回一个对象实例的引用。通过jc引用可以打开对话框。

    var jc = $.confirm({title: 'awesome'}); // jc will be used in the examples below

        jc.close():关闭对话框。
        var jc = $.confirm({
            ...
        })
        jc.close(); // destroy. 
    
        jc.isClosed():返回对话框是否被关闭的布尔值。
        jc.setTitle(string):设置标题。
        jc.setContent(string):设置内容。
        jc.setIcon(iconClass):设置按钮。
        jc.setDialogCenter():将对话框居中显示。
        jc.$body:别名:jc.$b,模态窗口对象。
        jc.$content:别名:jc.contentDiv。可以通过该对象来访问对话框的内容。
        var jc = $.confirm({
            content: 'Yeah, this is awesome'
        })
        console.log(jc.$content.html()); // Yeah, this is awesom
        jc.$title:可访问标题的对象。
        jc.$icon:可访问图标的对象。
        jc.$confirmButton:可访问确认按钮的对象。
        jc.$cancelButton:可访问取消按钮的对象。
        jc.$closeButton:可访问关闭按钮的对象。
        jc.$target:可访问点击元素的对象。
  • 相关阅读:
    将vue文件script代码抽取到单独的js文件
    git pull 提示错误:Your local changes to the following files would be overwritten by merge
    vue和uniapp 配置项目基础路径
    XAMPP Access forbidden! Access to the requested directory is only available from the local network.
    postman与newman集成
    postman生成代码段
    Curl命令
    POST方法的Content-type类型
    Selenium Grid 并行的Web测试
    pytorch转ONNX以及TnesorRT的坑
  • 原文地址:https://www.cnblogs.com/chen991126/p/14056592.html
Copyright © 2011-2022 走看看