This topic is locked
[SOLVED]

Toastr confirmation messages

10/28/2021 8:03:48 AM
PHPRunner General questions
L
Lance Spurgeon author

I have popup add and edit forms. I am trying after a user has saved on edit or add load a toastr notification. It loads before the event has happened. It currently loads the toast before the event has happened, it must show the toast only after the save has happened, any help please?.

On before display

$pageObject->AddCSSFile( "styles/custom/toastr.min.css" );
$pageObject->AddJSFile( "libs/js/toastr.min.js" );

After Record updated

$pageObject->stopPRG = true;
$pageObject->setProxyValue("saved", true);

OnLoad event

if (proxy['saved']){
toastr.info('User account has been updated - edit field', 'User Account', {
"closeButton": false,
"debug": false,
"newestOnTop": true,
"progressBar": false,
"positionClass": "toast-bottom-right",
"preventDuplicates": true,
"onclick": null,
"showDuration": "300",
"hideDuration": "10000",
"timeOut": "5000",
"extendedTimeOut": "1000",
"showEasing": "swing",
"hideEasing": "linear",
"showMethod": "fadeIn",
"hideMethod": "fadeOut"
});
};
L
Lance Spurgeon author 11/6/2021

I figured it out for anyone that would like to use something simular here you go

Setting Up Toast
List Page

1. After record deleleted
$_SESSION["toastr"] = "You have deleted ".$deleted_values["fullname"]." succesfully!";

2. Before Display
//Security::isAdmin();
$xt->assign("username", "");
$pageObject->AddCSSFile( "styles/custom/toastr.min.css" );
$pageObject->AddJSFile( "libs/js/toastr.min.js" );

$pageObject->setProxyValue("toastr", $_SESSION["toastr"]);

// 2 hours in seconds
$inactive = 5000;
$session_life = time() - $_session['toastr'];

if($session_life > $inactive){
unset($_SESSION['toastr']);
}

3. OnLoad
$('table').addClass('dataTable');

window.listPage = pageObj;
window.proxy = proxy;
$(document).ready(function(){
if (proxy['toastr']){
var res = (proxy['toastr']);
toastrTemplate(res,'Marketing Boards - Campaign Details');
};
});

Edit Page

1. After record Updated
$_SESSION["toastr"] = "You have updated ".$values["fullname"]." succesfully!";

2. OnLoad
this.on('afterSave', function() {
var pageObj = window.listPage;
Runner.runnerAJAX(Runner.pages.getUrl(pageObj.tName, pageObj.pageType)+"?a=return",
pageObj.ajaxBaseParams,
function(respObj){
pageObj.pageReloadHn.call(pageObj, respObj)
});
});

Add Page

1. After record added
$_SESSION["toastr"] = "You have added ".$values["fullname"]." succesfully!";

2. OnLoad
this.on('afterSave', function() {
var pageObj = window.listPage;
Runner.runnerAJAX(Runner.pages.getUrl(pageObj.tName, pageObj.pageType)+"?a=return",
pageObj.ajaxBaseParams,
function(respObj){
pageObj.pageReloadHn.call(pageObj, respObj)
});
});