JQuery Library Imported Inside JavaScriptAction

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

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
    i.e.
    import Foo from "./Foo"
    where Foo is the name of another JS action
  3. Import from javascriptsource directory
    i.e. 
    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

 

answered