This topic is locked

Insert Button feature with javascript cancel action

8/13/2010 9:23:05 AM
PHPRunner Tips and Tricks
F
FunkDaddy author

If you are using the "insert button" feature in Visual Editor (not just a standard HTML button, but rather the PHPRunner item that gives you the 3 tab option of before client, on server, and after client) and would like to be able to use a confirm dialog box whenever the button is pressed you will need to add this line of code before your javascript confirmation code:
this.setEnabled();
Then you can add a standard confirm dialog such as:
if (confirm('You have not checked off the "Are you sure you want to blah, blah, blah?')) {}

else {return;};


I was told that future versions of PHPRunner will not require "this.Enabled();" line, as it seems this was a very minor bug in latest version I was using Build 5482. For now, if you want to cancel the action after clicking the button you've inserted this is the best way to do it. Alternatively, you could forgo that line of code and simply add a "window.location.reload();" as part of your "if false" argument in your confirm statement... this would cancel the button click and reload page (reload is necessary because otherwise if you click on that button once, you will not be able to click on it again without refreshing the page). Anyhow, I recommend simply using the "this.setEnabled();" solution.
This is a minor tip & trick, but useful nonetheless for all of us in PHPR.
Cheers,

F
FunkDaddy author 10/23/2013

Minor update... "this.setEnabled();" no longer works in PHPR versions 6.2 and above (just tested with 6.2 and 7.0)... instead use "ctrl.setEnabled();" in the Client Before event of custom inserted buttons.

S
stiven 6/24/2016

Hey!
Nice tips you have provided in this forum. I was wondering if maybe you have come across the following situation. I added a button on the grid. I wanted the user to confirm before processing the event. I can do this with the confirm option in javascript, though I want to use a custom modals for alert messages. I can do this, but because it is a modal the button will be processed. Now I am wondering if there is any way to stop/pause the process of the button until the user confirms in the modal if they want to proceed or not?
Thanks,

Here is what I have. this is onClient before



swal({

title: "Are you sure?",

text: "This will be submitted for Payroll. No revision past this point.",

type: "warning",

showCancelButton: true,

confirmButtonColor: "#DD6B55",

confirmButtonText: "Yes, Process Hours!",

cancelButtonText: "No, Cancel!",

closeOnConfirm: true,

closeOnCancel: false },

function(isConfirm){

if(!isConfirm) {

swal("Cancelled", "Payroll was not processed.", "error");

return false;

}

});