I want some example using jQuery for widgets in Mendix

0
Hi, I want to try using jQuery for widgets but kinda lost where to start. I'd love to see some example of jQuery script used in JS snippets from the store, and I'll try to understand and follow it :) maybe you guys can give me something like, I have a button1 and how to set onclick event of it using jQuery. Thank you in advance !
asked
3 answers
2

I share the concerns of Andries but I think there are valid reasons to use jQuery, for example when you want to use a library with jQuery dependencies.

Back to the question, you can find some widgets in the app store that use jQuery. I suggest to copy the code from them. See the HTML widget - https://github.com/mendix/HTMLSnippet/blob/master/src/HTMLSnippet/widget/HTMLSnippet.js

I extracted the following snippet on how to load jQuery from a lib folder in the widget.

require(["HTMLSnippet/lib/jquery-3.3.1"], lang.hitch(this, function (jquery_3_3_1) {
   //do something with jQuery
}));

-Andrej

answered
0

Recommended not to use jQuery at all. 

- Size, of unused code

- Possible conflict between widgets libs

- All function for jQuery could be implemented with JavaScript in modern browsers

answered
0

Thanks for everyone's suggestions.

I think I will try to workaround with Javascript.

But how do I make my Javascript act like jQuery that works in real-time ?

Like if I resize my window... do function...

Thanks again !

answered