Enabling User Actions
Add interactive elements to your integration
<button {{action "doSomething"}}>Click Me!</button>polarity.export = PolarityComponent.extend({
message: '',
actions: {
doSomething: function (type) {
let self = this;
// The payload can contain any properties as long as you send a
// javascript object literal (POJO)
let payload = {
type: 'doSomething',
action: 'Button Clicked'
};
// This is a utility method that will send the payload to the server
//where it will trigger the integration's `onMessage` method
this.sendIntegrationMessage(payload).then(function (response) {
// We set the message property to the result of response.reply
self.set('message', response.reply);
}).catch(function (err) {
// If there is an error we convert the error into a string
// and append it to the string ERROR!
self.set('message', "ERROR! " + JSON.stringify(err));
});
}
}
});Last updated