To call a js function after load a script we can use the function loadScript()
To display a sweet-alert with html code use the function as shown below
loadScript: function(url, callback) {
var sweetalert = '<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/1.1.3/sweetalert.min.css">'
$('head').append(sweetalert);
var script = document.createElement("script")
script.type = "text/javascript";
if (script.readyState) { // only required for IE <9
script.onreadystatechange = function() {
if (script.readyState === "loaded" || script.readyState === "complete") {
script.onreadystatechange = null;
callback();
}
};
} else { //Others
script.onload = function() {
callback();
};
}
script.src = url;
document.getElementsByTagName("head")[0].appendChild(script);
},
self.loadScript('https://cdnjs.cloudflare.com/ajax/libs/sweetalert/1.1.3/sweetalert.min.js', function() {
swal({
title: "",
text: "PREVIEW NOT AVAILABLE FOR THIS SELECTION",
icon: "warning",
confirmButtonColor: 'black',
})
self.render();
})