正在甜蜜警报中加载 html?
Loading html inside sweet alert?
这是我调用 Swal 的代码:
window.swal({
title: "Checking...",
text: "Please wait",
imageUrl: "{{ asset('media/photos/loaderspin.gif') }}",
showConfirmButton: false,
allowOutsideClick: false
});
$.ajax({
type: 'POST',
url: '/' + target,
data: {
data: true
},
success: function(response) {
window.swal({
type: 'info',
width: 900,
padding: '3em',
html: response,
showCloseButton: true,
focusConfirm: false,
});
},
error: function(response) {
}
});
基本上我正在发出一个 ajax 请求,在控制器中执行 return view('index', compact('data'));
。
我试图在 Swal 中加载的 html 里面有一个 <script src="my-file.js"></script>
,但是当 Swal
被触发时它不会被加载,所以没有事件被触发当我点击里面。
我尝试查看文档,但找不到任何内容。我将如何让 swal 加载该文件?
我可以通过在 success
块中添加这一行来解决这个问题:
$.getScript('my-file.js')
这是我调用 Swal 的代码:
window.swal({
title: "Checking...",
text: "Please wait",
imageUrl: "{{ asset('media/photos/loaderspin.gif') }}",
showConfirmButton: false,
allowOutsideClick: false
});
$.ajax({
type: 'POST',
url: '/' + target,
data: {
data: true
},
success: function(response) {
window.swal({
type: 'info',
width: 900,
padding: '3em',
html: response,
showCloseButton: true,
focusConfirm: false,
});
},
error: function(response) {
}
});
基本上我正在发出一个 ajax 请求,在控制器中执行 return view('index', compact('data'));
。
我试图在 Swal 中加载的 html 里面有一个 <script src="my-file.js"></script>
,但是当 Swal
被触发时它不会被加载,所以没有事件被触发当我点击里面。
我尝试查看文档,但找不到任何内容。我将如何让 swal 加载该文件?
我可以通过在 success
块中添加这一行来解决这个问题:
$.getScript('my-file.js')