Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Custom widget and $(document).ready
Hi
I'm creating a custom widget using a public javascript image gallery based on jQuery. I've tried three and all of them include someting like this to bootstrap the gallery
$(document).ready(function() {
$(javascriptSelector).bootstrapGallery(..);
});
After a few tests I've found the problem is that when document is ready, $(javascriptSelector) is void, it has not elements inside, and for that reason bootstrap fails. It seems content load is deferred. If I put a button elsewhere to execute bootstrap, it works.
Ive tried with a setTimeout() delay execution. While $(javascriptSelector).size==0, it delays execution. I think it's not a safe way to know if the page is fully loaded. How can I be sure of that?
Thanks
I solved it by using JSNI. After loadin the gallery content I call the bootstrap function with a native function.
would you please post how you have created /compiled the custom widget. I want to use JSNI, and when I call the native function I get the following error
here is my other post with the problem
https://vaadin.com/wiki/-/wiki/Main/Creating+a+simple+component#_36_messageScroll1474604
at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:164)
at com.vaadin.ui.AbstractComponent.fireEvent(AbstractComponent.java:1187)
at com.vaadin.ui.Button.fireClick(Button.java:342)
at com.vaadin.ui.Button$1.click(Button.java:54)
... 76 more
Caused by: java.lang.UnsatisfiedLinkError: com.example.vaadinsample.VaadinsampleApplication.alert(Ljava/lang/String;)V
at com.example.vaadinsample.VaadinsampleApplication.alert(Native Method)
at com.example.vaadinsample.VaadinsampleApplication$2.buttonClick(VaadinsampleApplication.java:117)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:512)
... 80 more