Skip to content
Discussion options

You must be logged in to vote

Hi @PoshoDev,

In version 1.4.7 we introduced a simpler way to emit global events:

ui.add_head_html('''
    <script>
    function emitSize() {
        emitEvent('resize', {
            width: document.body.offsetWidth,
            height: document.body.offsetHeight,
        });
    }
    window.onload = emitSize;
    window.onresize = emitSize;
    </script>
''')

ui.on('resize', lambda e: print(f'resize: {e.args}'))

In my tests this emits the size when the page loads as well as when it is resized. Does this fulfil your needs?

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@PoshoDev
Comment options

Answer selected by PoshoDev
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants