[英]Loading html inside sweet alert?
Here is my code for callling Swal:这是我调用 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) {
}
});
Basically I'm making an ajax request that does a return view('index', compact('data'));
基本上我正在做一个 ajax 请求,它会return view('index', compact('data'));
in the controller.在控制器中。
The html that I'm trying to load inside Swal has a <script src="my-file.js"></script>
inside it, but it does not get loaded when Swal
is fired, so no events get fired when I click inside.我试图在 Swal 中加载的 html 里面有一个<script src="my-file.js"></script>
,但是当Swal
被触发时它不会被加载,所以当我被触发时没有事件被触发点击里面。
I've tried looking in the docs but I can't find anything.我试过查看文档,但找不到任何内容。 How will I get swal to load that file?我将如何让 swal 加载该文件?
我能够通过在success
块中添加这一行来解决这个问题:
$.getScript('my-file.js')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.