Giter Site home page Giter Site logo

Comments (10)

Lochemage avatar Lochemage commented on August 16, 2024

@arpanmukherjee1

Do you have a code sample? I'm not sure how you mean by hooking up the closed event after onCreate.

I've tried the closed event both inside the onCreate and with the resulting panel from wcDocker.addPanel and it worked fine for me.

from wcdocker.

arpanmukherjee1 avatar arpanmukherjee1 commented on August 16, 2024

@Lochemage

This is the simulated code sample. The actual code is bit complex to list down.

            function registerRender(self) {

                myDocker.registerPanelType(self.moduleName, {
                    isPersistent: false,  // explicit set to false. PERSISTENT_* event handlers not invoked
                    onCreate: function (panel) {

                        setTimeout(function () {
                            panel.on(wcDocker.EVENT.CLOSED, function (data) {
                                // THIS IS NOT CALLED
                                alert('CLOSED');
                            });

                            // These handlers are invoked
                            panel.on(wcDocker.EVENT.PERSISTENT_OPENED, function (data) {
                                alert('PERSISTENT_OPENED');
                            });

                            panel.on(wcDocker.EVENT.PERSISTENT_CLOSED, function (data) {
                                alert('PERSISTENT_CLOSED');
                            });

                        }, 10);

                        self.moduleObject.onRender(panel); 
                    }
                });
            }

from wcdocker.

Lochemage avatar Lochemage commented on August 16, 2024

@arpanmukherjee1

You may have to provide more; Using the code above, I've tried closing that panel when it was both initialized as part of the initial layout, when I manually created and closed it, and when it is both floating and docked.

It gave me the CLOSED alert every time.

I couldn't copy the self.moduleObject.onRender(panel); part though.

from wcdocker.

Lochemage avatar Lochemage commented on August 16, 2024

@arpanmukherjee1

Just wanted to give you a ping and see if you are still having this problem.

from wcdocker.

arpanmukherjee1 avatar arpanmukherjee1 commented on August 16, 2024

@Lochemage

Unfortunately yes, but i patched it. How it occurs, is still unknown to me. Maybe you can help in this case.

But I can show you why it occurs.

in panel.js

        __trigger: function (eventType, data) {
            if (!eventType) {
                return false;
            }

            if (this._events[eventType]) {
                /* NOTE: Temp fix for github #57 bug*/
                for (var i = this._events[eventType].length - 1; i >= 0; --i) {
                    this._events[eventType][i].call(this, data);
                }

                //for (var i = 0; i < this._events[eventType].length; ++i) {
                //    this._events[eventType][i].call(this, data);
                //}
            }
        },

At runtime the _events.length is 2. One is the panel handler and other that I added.
Now when the panel is closed the first handler removes itself from this array and length is updated to 1. This prevents my handler from being invoked.

I reversed the array and my handler is invoked first.

Hope that I explained the "why". If you can look into it why it is this way and generate the scenario at your end, that will be great.

from wcdocker.

Lochemage avatar Lochemage commented on August 16, 2024

@arpanmukherjee1

Ahh, that explains it! The panel itself does not use the closed event. Most likely you are using either a tabframe, iframe, or splitter inside your panel. These will register a closed event, and during that event it will un-register its own events causing your problem!

I've been able to reproduce your case now, and will have a fix for it in a few minutes.

from wcdocker.

Lochemage avatar Lochemage commented on August 16, 2024

@arpanmukherjee1

Please try this latest update and let me know if it fixed your problem.

from wcdocker.

arpanmukherjee1 avatar arpanmukherjee1 commented on August 16, 2024

@Lochemage

Yes, it's fixed now. Thanks.

But can you tell me the scenario that reproduces the issue?

from wcdocker.

Lochemage avatar Lochemage commented on August 16, 2024

@arpanmukherjee1

All you have to do is create either a wcTabFrame or a wcIFrame in your panel first before you register your CLOSED event handler. The tab frame and iframe both register their own CLOSED event handler onto your panel. When they are triggered, they clean themselves up by un-registering all the events they've added, among other things.

from wcdocker.

arpanmukherjee1 avatar arpanmukherjee1 commented on August 16, 2024

@Lochemage

Ok, got it.

from wcdocker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.