ideally when ia click a action item in my table it shows "show message" on clicking on to it i need a popup without the use of window.alert or alert instead show a pop up based on my website design
function showFailedWarning(){
dijit.byId('validationsForm').clearMessages();
dijit.byId('validationsForm').popup(alert("Upload Correct File "));
}
You can build your own pop-up with whatever design you want. Either hardcode the elements in HTML and set display:none
to the container in CSS, or dynamically append the container.
Note: Why I used innerHTML
in place of appendChild()
.
<button id="error">Click for error</button>
document.getElementById('error').onclick = function (event) {
event.preventDefault();
/*Creating and appending the element */
var element = '<div id="overlay" style="opacity:0"><div id="container">';
element += "<h1>Title</h1><p>Message</p>";
element += "</div></div>";
document.body.innerHTML += (element);
document.getElementById('overlay').style.display = "block";
/* FadeIn animation, just for the sake of it */
var fadeIn = setInterval(function () {
if (document.getElementById('overlay').style.opacity > 0.98) clearInterval(fadeIn);
var overlay = document.getElementById('overlay');
overlay.style.opacity = parseFloat(overlay.style.opacity, 10) + 0.05;
console.log(parseFloat(overlay.style.opacity, 10));
}, 50);
};
#overlay {
position:absolute;
top:0;
left:0;
width:100%;
height:100%;
z-index:1000;
background-color: rgba(0, 0, 0, 0.5);
opacity:0;
display:none;
}
#container {
position:absolute;
top:30%;
left:50%;
margin-left:-200px;
width: 400px;
height:250px;
background-color:#111;
padding:5px;
border-radius:4px;
color:#FFF;
}
You can use libraries such as jQuery UI
to achieve what you want:
<button id="error">Click for error</button>
$('#error').click(function (event) {
event.preventDefault();
$('<div id="container"><h1>Error</h1><p>Message</p></div>').dialog({
title: "Error"
});
});
Since you this question has the dojo tag and you have dijit code in your example, I would suggest using dijit.Dialog
to do this.
I put together a quick example on jsfiddle demonstrating it .
require(['dijit/Dialog', 'dijit/form/Button'], function (Dialog, Button) {
//create a new button (doesn't matter if it is programmatically or not)
var button = new Button({
label: 'Validate',
type: 'button'
});
button.placeAt(dojo.body());
button.on('click', function () {
//instantiate the dialog with our error message and content
var dialog = new Dialog({
title:'Error Message title',
content: '<div>Something is invalid!</div>',
style:'min-width:300px;'
});
//show the error message
dialog.show();
});
});
The dojo docs for dijit/Dialog should also be helpful to look at.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.