plugin development - Backbone event attachment:compat:ready can't hook

admin2025-06-05  2

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

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

Share Improve this question asked Dec 6, 2018 at 11:42 PawelCPawelC 213 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1
     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.

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1749109509a316440.html

最新回复(0)