Capture SilverStripe / Entwine to save a button

I'm trying to bind to the save button inside the GridField edit form, so the JavaScript function is executed before saving.

I tried the code below without success

$('button[type="submit"]').entwine({
    onclick: myFunction
});

What is javascript code to hook onclick event on GridField save button?

+4
source share
1 answer

This JavaScript bit will be called when the GridFieldsave button is clicked .

(function($) {
    $.entwine('ss', function($){
        $('#Form_ItemEditForm_action_doSave').entwine({
            onclick: function(e) {
                console.log('Hello there');
                this._super(e);
            }
        });
    });
})(jQuery);

In SilverStripe 3.5, the default identifier for the save button GridFieldis Form_ItemEditForm_action_doSave. When using the module, the BetterButtonsidentifier of the save button Form_ItemEditForm_action_save.

+6
source

Source: https://habr.com/ru/post/1665675/


All Articles