Skip to content

Instantly share code, notes, and snippets.

@jasonneylon
Created October 22, 2015 16:46
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 jasonneylon/ea5ea2fa79c97f86e693 to your computer and use it in GitHub Desktop.
Save jasonneylon/ea5ea2fa79c97f86e693 to your computer and use it in GitHub Desktop.
// publish an event when a user selects and address in our React component
onAddressSelected(addressIndex) {
this.state.selectedAddressIndex = addressIndex;
this.state.address = Object.assign({}, this.state.addresses[index]);
this.setState(this.state);
// using tinypubsub to wrap our js events
$.publish('address.selected', {address: this.state.address, type: this.props.addressType});
}
....
// subscrite in the page's JavaScript code
$.subscribe('address.selected', function(e, address) {
// update the form using jquery
...
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment