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) {

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 ??

     if (wp.media) {
            wp.media.view.AttachmentCompat.prototype.on("ready", function (e) {
                console.log("Kompat Ready mokor 12");

This event name is "ready" :) works now fine . Maybe this will help someone.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.