Is it possible to register a browser window resize (event) listener, within the widget code?
I have tried the following:
//widget code...
bind_: function (desktop, skipper, after) {
//...
jq(window).bind('resize', function () {console.log('Hello world 1!'); });
jq(window).on('resize', function () {console.log('Hello world 2!'); });
jq(window).resize(function (event) {console.log('Hello world 3!'); });
$(window).resize(function (event) {console.log('Hello world 4!'); });
jq.bind('resize', function () {console.log('Hello world 5!'); });
zk.afterMount(function() {
jq(window).bind('resize', function () {console.log('Hello world 6!'); });
jq(window).on('resize', function () {console.log('Hello world 7!'); });
jq.bind('resize', function () {console.log('Hello world 8!'); });
});
}, //end of bind
//rest of widget code..
and after the widget (and rest of my page code is loaded), resizing the browser window does not show any logs.
The indicated scenario above is simple, but in general, you could add some specific widget behavior on browser window resize.
I do not have the option of using a zul
page or add a separate <script>
element in the header of my html.
I have looked into the SO and zk forums and have found no real answer, simple or complex, to this.
UPDATE: it seems that calling it at widget "bind" time is too early; if it is called after the entire page (and all widgets) is loaded, then (and only then) the resize listener is registered.
After some more research, my problem is solvable via several ways: