Hello all. I have a bs popup with two buttons. One allows the user to stay on the page if necessary, while the other allows the user to leave the page if certain criteria are met. This button calls a js function which examines the criteria and directs the code accordingly.
If the criteria are not met, I have an alert() which informs the user of what the problem is and closes the popup when OK is clicked.
However I dont like having an alert, it seems a bit clumsy, and I would really like a popover to show up alongside the button instead. Try as I might I cant get this to happen. I can get the popover to work, but not by calling it from the script which examines the criteria. If someone could show me how to do this I would be very grateful. I have posted my code.
This shows the popup with the popover opened from the link, but I need to it to be called when the user clicks the green button.
If the criteria are not met, I have an alert() which informs the user of what the problem is and closes the popup when OK is clicked.
However I dont like having an alert, it seems a bit clumsy, and I would really like a popover to show up alongside the button instead. Try as I might I cant get this to happen. I can get the popover to work, but not by calling it from the script which examines the criteria. If someone could show me how to do this I would be very grateful. I have posted my code.
JavaScript:
<html>
(calls the popover from a link in the popup and works OK but I need it to be called by the js script)
<a href="#" data-toggle="popover" title="Printing is not complete!" data-content="<br>(You not have printed your Score or your Parts)">Toggle popover</a>
</html>
<script>
function showpopover() {
$('[data-toggle="popover"]').popover();
//alert ("Printing is not complete!\nYou not have printed your Score or your Parts");
//This alert is a test to see if the function is being called, and works OK, but the popover doesnt show.
}
</script>
<script>
// this redirects to the home page when the user clicks the
// 'Yes, I've printed everything' button in the
// 'Leaving this page?' modal popup
$('#popup7').on('hide.bs.modal', function (e) { // popup7 is closing
var tmpid = $(document.activeElement).attr('id'); // get the id of the 'Yes, I've printed everything' button
if (tmpid == "confirm-leave-button") {
//get values from hidden fields
var scr_prt = $("#scr_prt").val();
var pts_prt = $("#pts_prt").val();
//are Score and Parts printed?
if ((scr_prt == "score printed") && (pts_prt == "parts printed")) { //if score and parts printed
//ok to leave
window.location = 'https://www.fmtest.info/after_payment_selfprint_processed.php'; //go to processing page
} else {
//if score printed and parts NOT printed
if ((scr_prt == "score printed") && (pts_prt == "")) {
alert ("Printing is not complete!\nYou have printed your Score but not your Parts");
}
//if score NOT printed and parts printed
if ((scr_prt == "") && (pts_prt == "parts printed")) {
alert ("Printing is not complete!\nYou have printed your Parts but not your Score");
}
//if NOTHING has been printed
if ((scr_prt == "") && (pts_prt == "")) {
showpopover();
// $('[data-toggle="popover"]').popover(); (this doesn't work)
//alert ("Printing is not complete!\nYou not have printed your Score or your Parts"); (original alert box, this works OK)
} //if score printed and parts not printed
} //if score and parts printed (via else)
}
});
</script>
This shows the popup with the popover opened from the link, but I need to it to be called when the user clicks the green button.