Support

Account

Home Forums General Issues Extend and Override Parent Event Handler

Unread

Extend and Override Parent Event Handler

  • Hello!,

    I want to extend acf.validation so I have code like below.

    (function ($) {
        acf.validation = acf.validation.extend({
            _super: acf.validation,
    
            fetch: function ($form) {
                console.log('child fetch');
            },
    
            submit_form: function (e) {
                console.log('child submit form');
                e.preventDefault();
                return false;
            }
        });
    })(jQuery);

    Now my question is how to extend event handler such that it does not execute parent event handler.

    Here fetch is method it works fine, parent is not executed only child fetch method is only executed when acf.validation.fetch() is called. But submit_form is event handler and both parent and child handlers are executed when submit form event is fired. I can do like $(document).off('submit'); before declaring, but it seems like bad solution.

    Thanks in advanced for your replies.

    Thanks,
    Amit

Viewing 1 post (of 1 total)

The topic ‘Extend and Override Parent Event Handler’ is closed to new replies.