When to Use the Salesforce Console Integration Toolkit
Change a Visualforce Page by Using the Salesforce Console Integration Toolkit
addEventListener()
fireEvent()
removeEventListener()
Previous Versions
Removes a listener for a custom event type or a standard event type. This method removes a listener for custom event types in API version 25.0 or later; it removes a listener for standard event types in API version 30.0 or later.
For the list of standard events, see Methods for Console Events.
1sforce.console.removeEventListener( eventType: String, eventListener:Function, (optional)additionalParams:Object )| Name | Type | Description |
|---|---|---|
eventType | string | Event type for which eventListener is removed. |
eventListener | function | Event listener to remove. |
additionalParams | object | Optional parameters accepted by this method. The supported properties on this object are tabId: The ID of the tab to remove the listener for the specified event. This argument is only available in API version 30.0 or later. |
1<apex:page>
2 <apex:includeScript value="/support/console/68.0/integration.js"/>
3 <A HREF="#" onClick="testRemoveEventListener(); return false;">
4 Click here to remove an event listener for the 'SampleEvent' event type</A>
5
6 <script type="text/javascript">
7 var listener = function (result) {
8 alert('Message received from event: ' + result.message);
9 };
10 //Add a listener for the 'SampleEvent' event type
11 sforce.console.addEventListener('SampleEvent', listener);
12
13 function testRemoveEventListener() {
14 sforce.console.removeEventListener('SampleEvent', listener);
15 }
16 </script>
17</apex:page>None
1<apex:page>
2 <apex:includeScript value="/support/console/68.0/integration.js"/>
3 <A HREF="#" onClick="testRemoveEventListener(); return false;">
4 Click here to remove an event listener for the console 'CLOSE_TAB' event type</A>
5
6 <script type="text/javascript">
7 var tabId;
8
9 var onEnclosingPrimaryTabClose = function (result) {
10 alert('The enclosing primary tab is about to be closed. Tab ID: ' + result.id + ',
11 Object ID: ' + (result.objectId ? result.objectId : 'not available'));
12 };
13
14 //Add a listener to handle the closing of the enclosing primary tab
15 sforce.console.getEnclosingPrimaryTabId(function (result) {
16 if (result.id) {
17 tabId = result.id;
18 sforce.console.addEventListener(sforce.console.ConsoleEvent.CLOSE_TAB,
19 onEnclosingPrimaryTabClose, { tabId : tabId });
20 } else {
21 alert('Could not find an enclosing primary TAB!');
22 }
23 });
24
25 function testRemoveEventListener() {
26 sforce.console.removeEventListener(sforce.console.ConsoleEvent.CLOSE_TAB,
27 onEnclosingPrimaryTabClose, { tabId : tabId });
28 }
29 </script>
30</apex:page>None