I was trying to have a google iframe and for automation we were rendering our own iframe (By loading my url and gapi.iframes.getContext().openChild(options). Now I was not getting how to callback to the registered function on button click.
iframe.register('onproductselect', function(event) {
console.log(event);
}, gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER);
How can i call this above function when a dummy button is clicked ?
Declare the function outside of the listener. You can have the name of the function in the listener and call it wherever you want in your code (in the right scope).
function productSelectEvent(event) {
console.log(event);
}
iframe.register('onproductselect', productSelectEvent, gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER);
productSelectEvent({/* Custom event object */});