标签: sweetalert

如何使用甜蜜警报添加Ajax调用

我的Ajax方法看起来像这样

$.post(url,{
            ajax_call:"putDonation",
            addresse:addresse,
            phone:phone,
            email:email,
            name:name,
            amount:amount,
            amountinwords:amountinwords
           }).done(function(data){

            console.log(data);

            var arr = [];

            try {
                  var str = "";
                  //convert to json string
                      arr = $.parseJSON(data); //convert to javascript array
                      $.each(arr,function(key,value){
                        str +="<li>"+value+"</li>";
                    });
                       alert(str);
                       $(".alert-danger").show();
                       $("#error").html(str);

              } catch (e) {
                  swal("Jay Gayatri !", 'Donation Sucessful', "success")
                  $("#donation")[0].reset();
              }


           })
Run Code Online (Sandbox Code Playgroud)

我想展示一个像这样的甜蜜警报警告弹出窗口

   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!", …
Run Code Online (Sandbox Code Playgroud)

ajax jquery sweetalert

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

在sweetAlert中输入文本

我正在使用sweetalert的自定义版本来询问我的用户input.我已经设法使一切工作,但有一个奇怪的行为,为了能够在输入框中输入文本,你必须先点击屏幕:

swal({
    title: "Aggiornamento profilo",
    text: '<br /><form method="post" id="taxcode-update" name="taxcodeUpdate"><input id="admin-tax-code" minlength="3" class="form-control wedding-input-text wizard-input-pad" type="text" name="taxCode" placeholder="Codice fiscale"></form>',
    type: "warning",
    showCancelButton: false,
    confirmButtonText: "Aggiorna il mio profilo",
    closeOnConfirm: false
}, function () {
    swal("Deleted!", "Your imaginary file has been deleted.", "success");
});
Run Code Online (Sandbox Code Playgroud)

工作示例:https://jsfiddle.net/fvkppx06/

javascript jquery sweetalert

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

如何使用jQuery在texit中添加textarea标签作为输入元素

我不明白如何textareasweet警报中添加类型.相近type: "input"

$('#saveBtn).click(function(){
    swal({   
        title: "Enter your Name!",  
        text: "your name:",  
        type: "input",   
        showCancelButton: true,   
        closeOnConfirm: false, 
        showLoaderOnConfirm: true,
        animation: "slide-from-top",   
        inputPlaceholder: "Write something" }, 
        function(inputValue){  
             if (inputValue === false) 
                 return false;    
             if (inputValue === "") {
                swal.showInputError("You need to write something!");  
                return false
                }
            swal("Nice!", "You wrote: " + inputValue, "success"); 
         });
});
Run Code Online (Sandbox Code Playgroud)

这很好用.但如果我用 type: "textarea"而不是type: "input"

这给出了这样的错误:

sweetalert.min.js:1 Uncaught ReferenceError: logStr is not defined
Run Code Online (Sandbox Code Playgroud)

感谢帮助.

html javascript jquery css3 sweetalert

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

SweetAlert2 添加动态选项来选择输入

我想向SweetAlert2输入类型选择添加动态选项,如下所示:

swal({
title: 'Select Ukraine',
input: 'select',
inputOptions: {
  'SRB': 'Serbia',
  'UKR': 'Ukraine',
  'HRV': 'Croatia'
},
inputPlaceholder: 'Select country',
showCancelButton: true,
inputValidator: function(value) {
  return new Promise(function(resolve, reject) {
    if (value === 'UKR') {
      resolve();
    } else {
      reject('You need to select Ukraine :)');
    }
  });
}
}).then(function(result) {
  swal({
    type: 'success',
    html: 'You selected: ' + result
  });
})
Run Code Online (Sandbox Code Playgroud)

我想添加我自己保存在对象中的选项,而不是这 3 个国家。我怎样才能使用 javascript 做到这一点?

javascript sweetalert sweetalert2

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

将Sweet Alert弹出窗口添加到React组件中的按钮

我为Bootstrap和React(我在Meteor应用程序中使用)找到了这个完美的Sweet Alert模块:

http://djorg83.github.io/react-bootstrap-sweetalert/

但我不明白你如何在React组件中包含这些代码.

当有人点击我的应用程序中的删除按钮时,我想要一个Sweet Alert提示弹出要求确认.

这是删除按钮的组件:

import React, {Component} from 'react';
import Goals from '/imports/collections/goals/goals.js'
import SweetAlert from 'react-bootstrap-sweetalert';

export default class DeleteGoalButton extends Component {

  deleteThisGoal(){
    console.log('Goal deleted!');
    // Meteor.call('goals.remove', this.props.goalId);
  }

  render(){
    return(
      <div className="inline">
          <a onClick={this.deleteThisGoal()} href={`/students/${this.props.studentId}/}`}
          className='btn btn-danger'><i className="fa fa-trash" aria-hidden="true"></i> Delete Goal</a>
      </div>
    )
  }
}
Run Code Online (Sandbox Code Playgroud)

以下是我从Sweet Alert示例中复制的代码:

<SweetAlert
    warning
    showCancel
    confirmBtnText="Yes, delete it!"
    confirmBtnBsStyle="danger"
    cancelBtnBsStyle="default"
    title="Are you sure?"
    onConfirm={this.deleteFile}
    onCancel={this.cancelDelete}
>
    You will not be able to recover this imaginary file!
</SweetAlert>
Run Code Online (Sandbox Code Playgroud)

有人知道怎么做吗?

javascript twitter-bootstrap reactjs sweetalert

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

缺少甜蜜警报的选择选项

这可能是 ServiceNow 问题,但我添加了一个 Sweet Alert 来显示一个选择框,这样我就可以收集一个值以传递给下一条记录......但选择框没有显示,弹出窗口只是没有框或选项。我错过了什么?屏幕截图: 选择框警报

非常感谢,对我认为添加起来很简单的东西感到非常沮丧:)

swal({
  title: 'Select Outage Tier',
  input: 'select',
  inputOptions: {
    '1': 'Tier 1',
    '2': 'Tier 2',
    '3': 'Tier 3'
  },
  inputPlaceholder: 'required',
  showCancelButton: true,
  inputValidator: function (value) {
    return new Promise(function (resolve, reject) {
      if (value !== '') {
        resolve();
      } else {
        reject('You need to select a Tier');
      }
    });
  }
}).then(function (result) {
  swal({
    type: 'success',
    html: 'You selected: ' + result
  });
});
Run Code Online (Sandbox Code Playgroud)

sweetalert

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

突出显示sweetAlert中的默认文本输入

我有一个允许文本输入的SweetAlert2,我给它一个默认值.当警报弹出时,我希望突出显示此默认值,以便用户可以在需要时立即覆盖它.这是一个例子:

在此输入图像描述

以下是我使用sweetAlert选项调用的函数:

window.sweetPrompt = function (title, message, callback, input, keepopen, allowOutsideClick, allowEscapeKey) {
    sweetAlert({
        title: title,
        text: message,
        input: 'text',
        confirmButtonColor: "#428bca",
        preConfirm: function(text) {
            return new Promise(function(resolve) {
                if (!keepopen) {
                    resolve();
                } else {
                    callback(text);
                }
            });
        },
        inputValidator: function(text) {
            return new Promise(function (resolve, reject) {
                if (text) {
                    resolve();
                } else {
                    reject('Cannot be empty!');
                }
            });
        },
        inputValue: input,
        showCancelButton: true,
        reverseButtons: true,
        allowOutsideClick: allowOutsideClick,
        allowEscapeKey: allowEscapeKey
    }).then(callback, function(dismiss){});
};
Run Code Online (Sandbox Code Playgroud)

我将如何做到这一点(如果可能的话)?我想过使用jQuery,但我不知道如何获得sweetAlert对话的引用.任何建议,将不胜感激.

javascript jquery sweetalert sweetalert2

6
推荐指数
1
解决办法
2245
查看次数

SweetAlert2:设置对话框高度

对于 sweetAlert2 我注意到没有“高度”属性但有一个“宽度”属性,有没有办法将对话框的高度设置为 80%?

谢谢

https://limonte.github.io/sweetalert2/

javascript angularjs typescript sweetalert

6
推荐指数
1
解决办法
9092
查看次数

覆盖 R Shiny 模式对话框中的关闭按钮

我正在 R Shiny 中使用模态对话来获取用户的输入。在此表单中,默认有一个关闭按钮,单击该按钮即可关闭表单。我想在单击关闭按钮时添加确认弹出窗口(sweetAlert)。

我也准备使用 javascript,但我需要 sweetAlert 而不是 Windows 警报。我也无法成功生成 Windows 警报。

我如何覆盖这个内置“关闭”按钮的功能?我想在有人单击“关闭”时显示警告,并仅在他们确定时才让他们继续。否则我想让他们留在模式对话中。

任何帮助表示赞赏。

javascript r modal-dialog shiny sweetalert

6
推荐指数
1
解决办法
2447
查看次数

是否可以在 Sweet Alert 2 中添加整个角度组件?

例如,我想知道是否有一种方法可以使角度组件在甜蜜的警报框中打开

 Swal.fire(
  {
    HTML: '<app-exampleselector></app-exampleselector>',
  })
Run Code Online (Sandbox Code Playgroud)

我的目的是使用组件选择器,而不是在函数内编写代码,这反过来不是一个选项,因为我打算使用很多函数,包括数据库服务函数,这使得代码相当庞大。有没有办法做到这一点?或者我应该决定在新选项卡上打开该组件吗?

html sweetalert angular sweetalert2 angular9

6
推荐指数
1
解决办法
3127
查看次数