标签: sweetalert

甜蜜警报计时器 - 完成功能

我一直在玩SweetAlert插件:Sweet alert

我想创建一个删除按钮,在实际删除之前用户会收到提示.当用户再次按下"删除"时,则表示"已完成"并且用户必须再次单击"确定"才能提示离开.

SweetAlert有一个计时器功能,所以你可以在几秒钟左右后自动关闭最后一个"完成"提示,这很好.它们还有一个功能,您可以在用户在"完成"提示下单击"确定"时实现要运行的功能.问题是,如果定时器完成后提示自动关闭,则不运行该功能.

有什么想法可以做到这一点?

没有运行Timer和功能:

swal({
     title: "Deleted!",
     text: "Your row has been deleted.",
     type: "success",
     timer: 3000
     },
     function () {
            location.reload(true);
            tr.hide();
     });
Run Code Online (Sandbox Code Playgroud)

没有计时器,但有工作功能(点击"确定"按钮):

swal("Deleted!", "Your row has been deleted.", "success"), function () {
                        location.reload();
                        tr.hide();
                    };
Run Code Online (Sandbox Code Playgroud)

javascript jquery sweetalert

5
推荐指数
4
解决办法
5万
查看次数

带有JS表格的Sweet Alert(3输入)

我想在甜蜜警报中实现一个表单。我只能在其中输入一个标题和正文。

文档说,有一种自定义警报的方法,但是不允许从我的框架(customizecss.com)或从style.css加载类css3。

我正在尝试通过以下方式在警报中包含输入:

swal({
       title: "HTML <small>Title</small>!",
       text: "<input type='text'><label class='my-label'>Name</label>",
       html: true 
});
Run Code Online (Sandbox Code Playgroud)

而且它不起作用,仅显示标签...为什么?

我想知道是否有某种方法可以做到...

谢谢!

甜蜜警报-> https://github.com/t4t5/sweetalert

javascript forms html5 css3 sweetalert

5
推荐指数
1
解决办法
2万
查看次数

如何运行SweetAlert而不是默认的javascript确认方法

目前这是我用来运行基于"确认"类的正常确认窗口的代码.这一切都是通过href链接完成的,而不是onClick事件按钮.由于点击的结果是运行另一个被剪切的代码放在另一个文件中(意图删除db中的一行).

$('.confirmation').on('click', function () {
        return confirm('Er du sikker på at du vil slette?');
    });
Run Code Online (Sandbox Code Playgroud)

我想要的是用这个SweetAlert函数替换confirm方法

    swal({   
	title: "Are you sure?",   
	text: "You will not be able to recover this imaginary file!",  
	type: "warning", 
	showCancelButton: true,   
	confirmButtonColor: "#DD6B55",   
	confirmButtonText: "Yes, delete it!",   
	closeOnConfirm: false 
}, function(){   
	swal("Deleted!", "Your imaginary file has been deleted.", "success"); 
});
Run Code Online (Sandbox Code Playgroud)

任何人都知道如何做到这一点,当我尝试将sweetalert放在onClick函数中时会发生什么,警报会出现,但它会自动删除该行而不必确认任何内容,警报会消失.

javascript jquery sweetalert

5
推荐指数
2
解决办法
7619
查看次数

如何在使用'require'时从库加载CSS

我正在构建一个electron应用程序.在其中,我有webview一个preload脚本.在里面说的脚本,我想用sweetalert.

我安装sweetalertnpm install --save sweetalert.在我的脚本中,我加载它require('sweetalert')并调用它swal("Hello world!");.我现在注意到它看起来不正确,因为警报缺少其所需的CSS文件.但我正在加载它require('sweetalert'),这很好,因为它sweetalert可以保留在其目录里面node_modules而且我不必关心它,但它的CSS是它的一个组成部分,并且不会被拉出相同的方式.

现在,推荐的解决方法是什么?请记住,我在javascript文件中,并希望保持这种状态.我真的必须去获取CSS文件并以某种方式注入它吗?我怎么能正确地做到这一点,因为它在里面node_modules?在测试之后,由于内容安全策略,似乎无法在此特定情况下完成.

无论哪种方式,与require声明相比,这似乎很笨重,对于一个更简单的解决方案而言,它似乎很奇怪.

require webview node.js sweetalert electron

5
推荐指数
1
解决办法
1254
查看次数

甜蜜警报html选项

我正在尝试使用html选项发出甜蜜警报:

swal({  
   title: "HTML <small>Title</small>!",  
   text: "A custom <span style="color:#F8BB86">html<span> message.",   
   html: true 
});
Run Code Online (Sandbox Code Playgroud)

但是没有那个文字放一个按钮,我试过这个:

var boton = "button";
swal({   
    title: "HTML <small>Title</small>!",  
    text: "<input type=" + boton + ">",  
    html: true 
});
Run Code Online (Sandbox Code Playgroud)

但它不起作用!(我想制作一个带有选项的菜单(按钮))是否有人知道如何做这样的事情?谢谢!

html javascript css sweetalert

5
推荐指数
1
解决办法
1万
查看次数

将javascript数组转换为相同键/值的对象

我有一个返回数组的函数,如下所示:

在此输入图像描述

但我正在尝试填充SweetAlert2对话框.

正如文档所示,所需的输入将如下所示

inputOptions: {
    'SRB': 'Serbia',
    'UKR': 'Ukraine',
    'HRV': 'Croatia'
  },
Run Code Online (Sandbox Code Playgroud)

考虑到密钥与值相同,我怎样才能将我的数组转换为所需的格式?

所以,这样的结果将是结果:

{
    'aaa123': 'aaa123',
    'Açucena': 'Açucena',
    'Braúnas': 'Braúnas',
    [...]
}
Run Code Online (Sandbox Code Playgroud)

我试过了JSON.stringify,但输出不是我需要的:

"[[" AAA123" , "Açucena", "布劳纳斯","C.Fabriciano " "格格", "gegeq2", "伊帕廷加", "若阿内夏", "梅斯基塔", "Rodoviário", "睾丸中", "teste2", "TIMOTEO", "Tomatoentro", "TS"]]"

javascript arrays jquery sweetalert

5
推荐指数
1
解决办法
2万
查看次数

如何使用localize.js翻译跨js文件.例如SweetAlert2.js

我想在另一个js文件中使用jquery.localize.js(i18n json文件).让我们说sweetalerts2.

localize根据您选择的语言(EN,FR,GR)提供json文件中的翻译.(https://github.com/coderifous/jquery-localize)

Sweet Alert2是性感的弹出警报,不能被浏览器阻止,如常见警报,并为您提供全套选择,以使其看起来用户友好.(https://limonte.github.io/sweetalert2/)

但问题是如何根据用户选择的语言翻译Sweet Alert弹出窗口.

javascript jquery json localization sweetalert

5
推荐指数
1
解决办法
764
查看次数

在AngularJs中使用微调器的甜蜜警报对话框

我正在尝试在sweet alert类似于Bootstrap模态对话框(http://jsfiddle.net/D6rD6/5/)的对话框中显示微调框

我能想到的最接近的东西是这样的:

SweetAlert.swal({
title: '<small>Import errors occurred !</small>',
text: '<i class="fa fa-spinner" aria-hidden="true"></i>',
html: true,
customClass: 'manual-upload-errors-swal-width'
});
Run Code Online (Sandbox Code Playgroud)

如果这不可能,那么最近和最好的解决方案是什么?

javascript twitter-bootstrap angularjs bootstrap-modal sweetalert

5
推荐指数
1
解决办法
6227
查看次数

单击“取消”按钮后,SweetAlert调用代码

我已经编写了以下代码,我想在“取消”按钮下调用代码:

vm.saveGroup = function(){
    SweetAlert.swal({
        title: "Name this Device Group",
        text: "Please provide a name that you want your device group to be saved under. Also, make sure that you already specified all needed filters before you save the list.",
        type: "input",
        showCancelButton: true,
        closeOnConfirm: false,
        showLoaderOnConfirm: true,
        inputPlaceholder: "Device Group name"
    },
    function(inputValue){
        if (inputValue === false) {
            return false;
        }
        if (inputValue === "") {
            /*eslint-disable */
            swal.showInputError("You need to write something!");
            /*eslint-enable */
            return false;
        }

        deviceGroupsFactory.saveGroup(inputValue, …
Run Code Online (Sandbox Code Playgroud)

javascript angularjs sweetalert

5
推荐指数
1
解决办法
2万
查看次数

如何在甜蜜警报中显示我要上传的图像?

我有以下代码不起作用.我希望当输入改变时图像出现在swal(Sweet Alert)中,但我不知道什么不起作用.我在控制台上收到以下错误:

Failed to execute'readAsDataURL' on 'FileReader': parameter 1 is not type 'Blob'

INPUT

<input id="input" type="file" style="display:none;" onchange="muda()">
Run Code Online (Sandbox Code Playgroud)

脚本

<script>
            function muda(){
                var thefile = document.getElementById('input');
                var reader = new FileReader();
                    reader.onloadend = function(){
                        var imagem = reader.result;
                    }
                        if(thefile){
                            reader.readAsDataURL(thefile);
                        }
                swal({
                  title: "Esta é a imagem que pretende inserir?",
                  text: "<img src='"+imagem+"' style='width:150px;'>",
                  html:true,
                });
            }
        </script>
Run Code Online (Sandbox Code Playgroud)

UPDATE

有了adaneo响应,我设法读取文件名添加.files[0];但我现在不知道如何获取图像路径,我试图放置一个名为image的变量,你可以在代码中看到但它转undefined

javascript jquery filereader sweetalert

5
推荐指数
1
解决办法
8138
查看次数