Hi All
Apex 5.1
I have a requirement where I want to put a confirm on a select list change. The reason being is that changing it, has quite a big impact on other parts of the page (I have to clear certain values in a detail region), so if the user is changing it in error, then I want them to have the ability to cancel the change.
I thought the following would work:
create a global variable on the page
var entity_budget_cat_val;
Then a page load DA sets the initial value of entity_budget_cat
Then an on change dynamic action on the select list with the following:
if (!confirm("Are you sure you wish to change Entity Budget Category? Invoice Line items will need updating with new Budget Codes")) {
$s('P37_ENTITY_BUDGET_CAT',entity_budget_cat_val); // set old value
return; //abort!
}
entity_budget_cat_val = $v('P37_ENTITY_BUDGET_CAT'); // set global variable with new value
I thought it would work, except the change triggers the event again, so it goes into an endless loop.
I then a tried mouse click event, which fires before the change as soon as the user clicks on the Select, and gives them the opportunity to cancel. This avoids setting and unsetting the value and getting into a loop. However even if they cancel, the dropdown list opens up. I've tried focusing away on the cancel using $('#P37_ID').focus() , but it doesn't work (I'm assuming because the original event continues after the confirm closes).
If anyone has an elegant solution, id be grateful..
Thanks