Skip to content

Instantly share code, notes, and snippets.

@bensampaio
Created January 7, 2020 12:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bensampaio/49c8291e2c23f13f1f59242f2abf5d2d to your computer and use it in GitHub Desktop.
Save bensampaio/49c8291e2c23f13f1f59242f2abf5d2d to your computer and use it in GitHub Desktop.
Example of component method that performs an action when a form inside an iframe is submitted
class IFrame extends PureComponent {
// ...
bindEventsToFormsInIframe(iframeElement) {
const { contentDocument, contentWindow } = iframeElement;
jQuery(contentDocument).on('submit', '#account-form', () => {
jQuery(contentWindow).on('unload', () => {
// Dispatch redux action responsible for fetching and updating the account
dispatch({ type: 'FETCH_ACCOUNT' });
});
});
}
// ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment