Javascript event for after save

Silverstripe Version: 5.0


Is there any events to hook into for after a DataObject has been saved?

I show/hide some fields with js onload and on click. Clicking save, saves the form but doesn’t fire onload again.

At the moment I have a click event on the save button with a setTimeout it works but is pretty crude…

$.entwine('ss', function($){
        onclick: function(e) {

            }, 2000);

Is there a better way to do this in js or any way to know when it’s after save?

Take a look at the entwine docs - you probably want an onmatch handler for some relevant element on the form (or perhaps for the form itself) which will trigger every time that element is added to the DOM.

Because Silverstripe CMS is in a sort-of-partially-implemented-single-page-app, getting the right event handler with native events is tricky.

I see. I put it in the existing onmatch for the dependent-checkboxset-field and that is working.


1 Like