How to dynamically change title an Oracle Apex Page Modal?

Viewed 39

I have a single modal page for creating, editing and deleting products.

When P2_TYPE = 'UPD' the update button is displayed, when P2_TYPE = 'DEL' the delete button is displayed, when P2_TYPE = 'ADD' the new button is displayed.

I have created a dynamic action when the page loads using javascript.

function cambiarTitulo(){
var type; 
type = apex.item( "P2_TYPE" ).getValue();

if ((type == 'UPD' ) || (type == 'DEL' )){
apex.util.getTopApex().jQuery(".ui-dialog-content").dialog("option", "title", "Details")
}else{
apex.util.getTopApex().jQuery(".ui-dialog-content").dialog("option", "title", "New")
} 
}

But it is not working, it does not change the title

2 Answers

Use a new page item i.e P2_TITLE and set the value of it when you open the modal from the main page. Then in the modal page's page attributes, set title to:

&P2_TITLE.

Try this snippet in "Execute when page loads":

var type = apex.item( "P2_TYPE" ).getValue();
var title = (
  pgitem === 'UPD' ? 'Details' : // if 
  pgitem === 'DEL' ? 'Details' : // else if 
  'NEW' // else 
);
$('.ui-dialog-title',parent ? parent.document : document).text( title);
Related