How can I run a function when a parent Record View function runs?

I am building a customisation that extends a view (BaseProductBundlesQuoteDataGroupListView) that already extends the BaseRecordView and I need one of my custom functions to run after a new record is saved.

I've found that there are save() and handleSave() functions in BaseRecordView, but I have been unable to extend or _.wrap() them in any way I could find. Running my function on this.context.get('parentModel').on('save') or 'saved' does not work at all. I have also tried runing it on this.parent.context.on('button:save_button:click'), but nothing happens.

Do you know how to do this efficiently without messing around with creating an additional view and duplicating my custom methods?

May I should build this the other way around and extend  the Quotes record view, getting and using the child view of BaseProductBundlesQuoteDataGroupListView?

Parents Reply
  • The first and main part of the customisation is that the related models are changed as the user changes the current model. So my goal is to re-use the same function on a new save.

    The reason it needs to happen after save is that when you add Quoted Line Items in create view, they are not really added before you save. In the record view they can be added individually.

    I can indeed use a before_save logic hook, but that would mean re-writing the JS function into PHP, which is not an efficient practice.

    As an alternative, I tried to run the same function on record view initialise, but that didn't work.

Children
No Data