Backbone event attachment:compat:ready can’t hook

I want to ask question about events in backbone. I have problem to run some function when hook is triggerd.

I want to

wp.media.view.AttachmentCompat.prototype .on(“attachment:compat:ready”, function (e) {
console.log(“READYY”);
});

But this isn’t working. What object handle the events of AttachmentCompat ?
Maybe i do it to early ?

I was able to run my function by extending , but for me isn’t best way.

var AttachmentCompatNew = wp.media.view.AttachmentCompat.extend({
postSave: function () {
this.controller.trigger(‘attachment:compat:ready’, [‘ready’]);

}
});

wp.media.view.AttachmentCompat.prototype = AttachmentCompatNew.prototype;

Can some one help me to understand how i can trigger my functions on diffrent events ??

Read more here:: Backbone event attachment:compat:ready can’t hook

Leave a Reply

Your email address will not be published. Required fields are marked *