This function is in a very big hierarchy of js functions so can't use html from views else I will lose all parameters as there are many parameters being passed in each script.
Using bootbox.js for this prompt -- because it has password masking in the prompt the not working code. I need to wait for callback instead of completing the execution of remaining script after showing the prompt.
function authorize() {
alert("Script has started...");
var final_result = 0;
bootbox.prompt({
title: "This is a prompt with a password input!",
inputType: 'password',
callback: function(result)
{
if (result!=null)
{
final_result = 1;
} else {
final_result = 0;
}
}
});
alert("calling XYZ");
function xyz();
alert("Script has finished... final result is" + final_result);
}
The working code with default JavaScript prompt -- want like this (using bootboxjs just to mask the input as I'm using this for password):
function authorize() {
alert("Script has started...");
var final_result = 0;
let text = prompt("This is a prompt with a password input!", "")
if (text!= null) {
final_result = 1;
} else {
final_result = 0;
}
alert("calling xyz" );
function xyz();
alert("Script has finished... final result is" + final_result );
}
This is covered in the documentation, many times:
Given your example, this is what I'm assuming you're after:
To reiterate: Bootstrap modals are just positioned
<div>elements, and themodal()function is just hiding and showing them.If you really want a customizable prompt that does block program execution, your only option is
<dialog>(see MDN). It's only recently gained enough browser support to be usable, though, so use at your own risk.