Skip to content

Instantly share code, notes, and snippets.

@perrupa
Created April 13, 2017 18:59
Show Gist options
  • Save perrupa/5989b3dc32c0b3c194e3abb5c1c197c6 to your computer and use it in GitHub Desktop.
Save perrupa/5989b3dc32c0b3c194e3abb5c1c197c6 to your computer and use it in GitHub Desktop.
const modalUrl = '/path/to/modal/contents.html';
// This function is executed in the Channel's original iframe
function applyCallback(label) {
// This is the magic line here. -----\
// |
// V
const modalDom = ShopifyApp.Modal.window().window.document
const form = modalDom.getElementById('VariantForm');
SellOnAmazon.someAwesomeFunction(form);
ShopifyApp.Modal.close();
}
//Called from within the Embedded App to open the modal.
ShopifyApp.Modal.open({
src: modalUrl,
title: 'My Sweet EmbeddedApp Modal',
buttons: {
primary: {
label: 'Apply changes',
callback: applyCallback
},
secondary: {
label: 'Cancel',
callback: function(label) {
ShopifyApp.Modal.close();
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment