Backbone events for Linking/Unlinking a Record

Hi,

Is there a way in javascript to listen for a linking or unlinking of a record (ie in a sub-panel)?

In an extended Case RecordView, I've tried monitoring this.model.on('all', ...) and also this.model.getRelatedCollection('contacts_cases').on('all') but nothing seems to reliably fire when I link or unlink a contact.

I know I can do this in php via a logic hook, but I was hoping for a front-end solution.

Any tips or guidance greatly appreciated.

Thanks.

Gary.

  • All the code is in clients/base/fields/link-action/link-action.js (try jssource/src_files/clients/base/fields/link-action.js if it's minified) -  specifically the selectDrawerCallback function links the records using app.data.createRelatedBean, and has a callback to  this.context.get('collection').resetPagination(); and this.context.set('collapsed', false); to refresh the subpanel. Read the code there.

    You could extend link-action and override that event, or have a callback on createRelatedBean.

  • Backbone Events for Sidecar buttons are typically triggered on the current context or layout instead of the model object.

    Try using this.context.on('all', ... );

    App Ecosystem @ SugarCRM

  • Thanks, I find I'm still finding my way around the framework. The layout in question above would be a subpanel and not record.js, am I correct? Or does the record subsume the subpanel?

  • Correct, the Record View does not contain the subpanels. The Record Layout includes the Record View and the Subpanels layout which defines each of the individual subpanels as subcomponents. What is shared across all these different components is the Context object. Without it, inter-component communication is pretty hard.

    One of the nice features of the Sidecar Dev Tools is the ability to navigate the layout/view/field component hierarchy of the current page visually. 

    GitHub - sugarcrm/SidecarDevTools: Browser extension for Sugar 7 Sidecar framework development 

    App Ecosystem @ SugarCRM