JQuery Library Imported Inside JavaScriptAction

how can we import a jquery library inside javascriptaction in mendix ?                Thanks In Advance.
1 answers

Hi Narendran,

Javascript actions can import code from other sources in 3 main ways:

  1. Access globally-declared variables – i.e. scripts included in your index.html
  2. Import from other JS actions
    import Foo from "./Foo"
    where Foo is the name of another JS action
  3. Import from javascriptsource directory
    import Bar from "./path/to/bar.js"
    where bar.js is another js file in your project folder.


However, I should caution you against including jQuery for the purposes specified in your original post. Adding and removing classes is a very lightweight function that you really don’t need jQuery to achieve. You could simply rewrite your code like this in plain old javascript (POJS)

document.querySelector('.userFormpane').classList.add("opened") // add class

or you could use the standard Mendix platform Conditional Visibility functionality to hide and show your content. Either of these methods would be a more maintainable (and lightweight) solution to what it seems you’re trying to achieve