Support

Account

Home Forums General Issues Extending field in JavaScript, can I call the parent method?

Unread

Extending field in JavaScript, can I call the parent method?

  • Hello, If I extend an existing field in javascript with

    const ImageExtends = acf.models.ImageField.extend({

    And I wish to create a replacement function, lets say removeAttachment, is there a way to invoke the parent method so I can avoid having to duplicate the original method/functions body? I still want to call the original remove, but do some extra work either side of that call.

    eg the PHP equivalent in a class is parent::someMethod() from within someMethod on child.

    I found that…

    // Set a convenience property in case the parent's prototype is needed later.
    //Child.prototype.__parent__ = Parent.prototype;

    …is commented out, does this elude to this being intentionally disabled?

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.