Skip to content

Instantly share code, notes, and snippets.

@beckettkev
Created March 18, 2016 15:59
Show Gist options
  • Select an option

  • Save beckettkev/605e716393ba61df8cd9 to your computer and use it in GitHub Desktop.

Select an option

Save beckettkev/605e716393ba61df8cd9 to your computer and use it in GitHub Desktop.
Loading a SPModal window in SP passing the parent window location
function getWindowLocation() {
var caller = '';
['protocol','//','hostname','pathname'].forEach(function(item, i) {
caller += item === '//' ? item : window.location[item];
});
return caller;
}
function loadTemplatePicker() {
var _options = {
tite : 'Template Picker',
url : <INSERT URL HERE>,
allowMaximize : false,
showClose : true,
autoSize : true,
width: 560,
height : 560,
args: { parentLocationUrl: getWindowLocation() },
dialogReturnValueCallback : close
};
SP.SOD.execute('sp.ui.dialog.js', 'SP.UI.ModalDialog.showModalDialog', _options);
}
//Meanwhile we will need to get the property on the target page being loaded in the modal window...
var args = SP.UI.ModalDialog.get_childDialog().get_args();
console.log(args.parentLocationUrl);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment