calling modal pop-up window from button, using dynamic actions
KarenHMar 1 2012 — edited May 23 2013I am using apex 4.1. I have a page that I would like to call several different pop-up windows from. I am able to call a pop-up window using a column link, but unable to do so from a button.
Here is what I currently have.
dynamic action - MODAL DIALOG
event: CLICK
selection type: jQuery Selector
jQuery Selector: a[id^=callModalDialog],button[value=CREATE]
true action: executeJavascript code
fire when event: TRUE
event scope: LIVE
/* prevent default behaviour on click */
var e = this.browserEvent;
e.preventDefault();
/* Find page link */
var link;
if (this.triggeringElement.tagName=='A') {
link = this.triggeringElement.href;
} else if (this.triggeringElement.tagName=='BUTTON') {
link = this.triggeringElement.title;
}
/* Trigger JQuery UI dialog */
var horizontalPadding = 30;
var verticalPadding = 30;
$('<iframe id="modalDialog" src="' + link + '" />').dialog({
title: "Endorsements",
autoOpen: true,
width: 600,
height: 500,
modal: true,
close: function(event, ui) {apex.event.trigger('#P311_AFTER_MODAL','select',''); $(this).remove();},
overlay: {
opacity: 0.5,
background: "blue"}
}).width(600 - horizontalPadding).height(500 - verticalPadding);
return false;
my second DYNAMIC ACTION is ON PAGE LOAD
event: PAGE LOAD
action: EXECUTE JAVA SCRIPT
Fire when event: TRUE
true action:
/* get original onclick event */
var origAction = $('button[value=CREATE]').attr('onclick').toString();
/* get link from original onclick event using regular expression */
var link = origAction.match(/(redirect\((\'|\"))([^\'\)|\"\)]*)/)[3];
/* Remove original onclick event */
$('button[value=CREATE]').removeAttr('onclick');
/* store link as title attribute of button */
$('button[value=CREATE]').attr('title', link);
when the popup is called from a column link, I have the link attribute set to : id="callModalDialog#PERMIT_ID#". This works perfectly. The page (page 311) that is called appears as a modal popup.
when the popup is called from a button (NOTE: THIS IS TO CALL A DIFFERENT PAGE, page 86), the action is REDIRECT TO PAGE IN APPLICATION. The page is called, but not as a modal popup, only as a regular page.
thanks for any help. Karen