Created
January 7, 2020 12:35
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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