Publishing a Canvas Event from a Visualforce Page
The following code example shows how to call the publish method to publish the myevent event from a Visualforce page. Any canvas app that subscribes to this event will receive the event.
// Target all canvas apps.
Sfdc.canvas.controller.publish({name : 'mynamespace.myevent',
payload : {}});
The following code example shows how to call the publish method to publish an event to a specified canvas app from the Visualforce page.
If an event is published to specific canvas apps, even if other canvas apps on a Visualforce page are subscribed to it, only the canvas apps specified will receive that event. Using this code example, if the Visualforce page contained canvas apps app1, app2, and app3, and they all subscribed to myevent, only app1 would receive the event.
// Target a specific canvas app
// where "app1" is the canvasId specified in the canvas component.
// For example: <apex:canvasApp canvasId="app1">
Sfdc.canvas.controller.publish({name : 'mynamespace.myevent',
payload : {},
target : {canvas : 'app1'}});
In the target parameter, you can specify multiple canvas apps by passing in an array of canvas apps: target : [{canvas : 'app1'}, {canvas: 'app2'}].