Revision history [back]

click to hide/show revision 1
initial version

answered 2018-08-28 10:49:06 +0800

cor3000 gravatar image cor3000

ZK Team

Thanks for sharing your solution ... I'd like to point that this will affect all kinds of windows, not only the modal windows... and any visibility change of an embedded (into the page flow) would also trigger the css class so I propose this client side override to only affect windows in modal-mode.

zk.afterLoad('zul.wnd', function() {
    var xWindow = {};
    zk.override(zul.wnd.Window.prototype, xWindow, {
        setVisible : function(visible) {
            if(this.getMode() == 'modal') {
                jq(document.body).toggleClass('modal-open', visible)
            }
            xWindow.setVisible.apply(this, arguments);
        }
    });//zk.override
});//zk.afterLoad

By using zk.override you don't have to copy the content of the original method and you can simply call from the backup object.

Still this code doesn't cover nested modal windows ... if that's an issues additional logic would be needed.

Thanks for sharing your solution ... I'd like to point that this will affect all kinds of windows, not only the modal windows... and any visibility change of an embedded (into the page flow) would also trigger the css class so I propose this client side override to only affect windows in modal-mode.

zk.afterLoad('zul.wnd', function() {
    var xWindow = {};
    zk.override(zul.wnd.Window.prototype, xWindow, {
        setVisible : function(visible) {
            if(this.getMode() == 'modal') {
                jq(document.body).toggleClass('modal-open', visible)
            }
            xWindow.setVisible.apply(this, arguments);
        }
    });//zk.override
});//zk.afterLoad

By using zk.override you don't have to copy the content of the original method and you can simply call from the backup object.

Still this code doesn't cover nested modal windows ... if that's an issues additional logic would be needed.

runnable example on zkfiddle

Thanks for sharing your solution ... I'd like to point out that this will affect all kinds of windows, not only the modal windows... and any visibility change of an embedded (into the page flow) would also trigger the css class so I propose this client side override to only affect windows in modal-mode.

zk.afterLoad('zul.wnd', function() {
    var xWindow = {};
    zk.override(zul.wnd.Window.prototype, xWindow, {
        setVisible : function(visible) {
            if(this.getMode() == 'modal') {
                jq(document.body).toggleClass('modal-open', visible)
            }
            xWindow.setVisible.apply(this, arguments);
        }
    });//zk.override
});//zk.afterLoad

By using zk.override you don't have to copy the content of the original method and you can simply call from the backup object.

Still this code doesn't cover nested modal windows ... if that's an issues additional logic would be needed.

runnable example on zkfiddle

Thanks for sharing your solution ... I'd like to point out that this will affect all kinds of windows, not only the modal windows... and any visibility change of an embedded (into the page flow) would also trigger the css class so I propose this client side override to only affect windows in modal-mode.

zk.afterLoad('zul.wnd', function() {
    var xWindow = {};
    zk.override(zul.wnd.Window.prototype, xWindow, {
        setVisible : function(visible) {
            if(this.getMode() == 'modal') {
                jq(document.body).toggleClass('modal-open', visible)
            }
            xWindow.setVisible.apply(this, arguments);
        }
    });//zk.override
});//zk.afterLoad

By using zk.override you don't have to copy the content of the original method and you can simply call the original method from the backup object.object xWindow.

Still this code doesn't cover nested modal windows ... if that's an issues additional logic would be needed.

runnable example on zkfiddle

Thanks for sharing your solution ... I'd like to point out that this will affect all kinds of windows, not only the modal windows... and any visibility change of an embedded (into the page flow) would also trigger the css class so class. I propose this client side override to only affect windows in modal-mode.

zk.afterLoad('zul.wnd', function() {
    var xWindow = {};
    zk.override(zul.wnd.Window.prototype, xWindow, {
        setVisible : function(visible) {
            if(this.getMode() == 'modal') {
                jq(document.body).toggleClass('modal-open', visible)
            }
            xWindow.setVisible.apply(this, arguments);
        }
    });//zk.override
});//zk.afterLoad

By using zk.override you don't have to copy the content of the original method and you can simply call the original method from the backup object xWindow.

Still this code doesn't cover nested modal windows ... if that's an issues issue additional logic would be needed.

runnable example on zkfiddle

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More