in implementation guides ~ read.
Jsapi Chatteranswers

Jsapi Chatteranswers

DOWNLOAD

First things first !
To download this implementation guide, click the download button below.
If you need more information about the implementation guide, you can read the Table of Contents below.

Download

Chatter Answers JavaScript API

Reference
Salesforce Spring

salesforcedocs
Last updated November

Copyright Salesforce Inc All rights reserved Salesforce is a registered trademark of Salesforce Inc as are other

names and marks Other marks appearing herein may be trademarks of their respective owners

CONTENTS

Chatter Answers JavaScript API Reference

Chatter Answers JavaScript API Events

HOVERUSER

FEEDREADY

FEEDITEMSELECTED

EDITMYSETTINGSCLICK

Chatter Answers JavaScript API Methods

publish
subscribe

CHATTER ANSWERS JAVASCRIPT API REFERENCE

The Chatter Answers JavaScript API helps you mediate communication to the Chatter Answers UI Learn the standard events and methods

that you can use to customize the behavior of Chatter Answers UI components

Note The Chatter Answers JavaScript API is currently available through a pilot program For information on enabling Chatter

Answers JavaScript API for your organization contact Salesforce

By using the Chatter Answers JavaScript API you can listen to events that are fired in the application You can also register your own

listeners for those events

IN THIS SECTION

Chatter Answers JavaScript API Events

The Chatter Answers JavaScript API has four events

Chatter Answers JavaScript API Methods

The Chatter Answers JavaScript API has two methods

Chatter Answers JavaScript API Events

The Chatter Answers JavaScript API has four events

Note The Chatter Answers JavaScript API is currently available through a pilot program For information on enabling Chatter

Answers JavaScript API for your organization contact Salesforce

Use these events to modify the behavior of Chatter Answers UI components

IN THIS SECTION

HOVERUSER

The HOVERUSER event mediates communication to the Chatter Answers reputation hover UI module

FEEDREADY

The FEEDREADY event indicates that the Chatter Answers feed completed loading

FEEDITEMSELECTED

Triggered when a search result from the SearchAsk component is selected

EDITMYSETTINGSCLICK

Triggered by default when the Edit My Settings link is clicked

HOVERUSER

The HOVERUSER event mediates communication to the Chatter Answers reputation hover UI module

For example when users hover over a user profile picture the HOVERUSER event is triggered and you can register a callback to listen

to this event

Chatter Answers JavaScript API Reference

FEEDREADY

Payload
Payload object

Description

userId

ID of the user

communityId

Zone ID of the feed item hovered over

targetId

Reference to the target DOM element hovered over

Example

sforceanswerseventstypeHOVERUSER

publish Example for HOVERUSER

var answers sforceanswers

answerseventspublishanswerseventstypeHOVERUSER

subscribe Example for HOVERUSER

var answers sforceanswers
var myHandler functionevtData

alertNow I am also listening to the HOVERUSER event

answerseventssubscribeanswerseventstypeHOVERUSER myHandler this

FEEDREADY

The FEEDREADY event indicates that the Chatter Answers feed completed loading

This event is fired by Chatter Answers You should trigger other custom events only after FEEDREADY is fired This event cannot be

overridden

Payload
None

Example
var myHandler function
alertThe Feed is ready

answerseventssubscribeanswerseventstypeFEEDREADY myHandler

FEEDITEMSELECTED

Triggered when a search result from the SearchAsk component is selected

Chatter Answers JavaScript API Reference

EDITMYSETTINGSCLICK

This event causes the feed to display the selected item in single item view FEEDITEMSELECT can be published to cause the feed to

display a feed item in single item view At least one Chatter Answers component or the allfeeds component must be present

on the Chatter Answers page for this event to fire FEEDITEMSELECT can be subscribed to in order to register additional callbacks to

the event The default handler of the event cannot be overridden

Payload

ID of the feed item to be rendered in single item view

publish Example for FEEDITEMSELECTED

var answers sforceanswers

answerseventspublishanswerseventstypeFEEDITEMSELECTED idfeeditemid

subscribe Example for FEEDITEMSELECTED

var myHandler functionevtPayload
alertFeed item with id evtPayloadid was selected

answerseventssubscribeanswerseventstypeFEEDITEMSELECTED myHandler

EDITMYSETTINGSCLICK

Triggered by default when the Edit My Settings link is clicked

The default handler causes the My Settings overlay to appear The EDITMYSETTINGS event can be published to cause the My Settings

overlay to display The overlay appears only if a user is logged in and at least one Chatter Answers component is on the page This event
can be subscribed to allowing a registered callback However this event doesnt override the default behavior of the My Settings overlay

Payload
None

publish Example for EDITMYSETTINGSCLICK

var answers sforceanswers

answerseventspublishanswerseventstypeEDITMYSETTINGSCLICK

subscribe Example forEDITMYSETTINGSCLICK

var myHandler function
alertMy settings link was clicked

answerseventssubscribeanswerseventstypeEDITMYSETTINGSCLICK myHandler

Chatter Answers JavaScript API Reference

Chatter Answers JavaScript API Methods

Chatter Answers JavaScript API Methods

The Chatter Answers JavaScript API has two methods

Note The Chatter Answers JavaScript API is currently available through a pilot program For information on enabling Chatter

Answers JavaScript API for your organization contact Salesforce

forceanswersevents is the namespace for the Chatter Answers JavaScript API methods type refers to an event in a method

Use these methods for the Chatter Answers Javascript API events

IN THIS SECTION

publish
Use publish to fire an event
subscribe
Use subscribe to subscribe to an event

publish
Use publish to fire an event

Parameters
Parameter

Description

eventType

Event type being fired

Example
var answers sforceanswers

answerseventspublishanswerseventstypeHOVERUSER

subscribe
Use subscribe to subscribe to an event

Parameters
Parameter

Description

eventType

Event type to listen to

handler

Handler function to execute when this event is fired

context

Optional Context in which the above handler function should be
executed
Values

Chatter Answers JavaScript API Reference

subscribe

null
this
some context
override

Optional Override the default handler for this event
Values
true
false

Examples
Example To register my handler for an event
var answers sforceanswers
var myHandler functionevtData

alertNow I am also listening to the HOVERUSER event

answerseventssubscribeanswerseventstypeHOVERUSER myHandler this

or

answerseventssubscribeanswerseventstypeHOVERUSER myHandler

var answers sforceanswers

answerseventspublishanswerseventstypeHOVERUSER

Example To register a handler for an event by overriding the default behavior for that event
var answers sforceanswers
var myOverridenHandler functionevtData
consolelogUser id evtDatauserId
consolelogCommunity id evtDatacommunityId
consolelogTarget Element Id evtDatatargetId

answerseventssubscribeanswerseventstypeHOVERUSER myOverridenHandler null true

***