What is the right way to include jquery.min.js and jquery-ui.min.js in a UI Page and UI Script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-25-2016 09:02 AM
As mentioned in the title I am trying to add jquery to my UI Page.
I was able to add jquery.min.js to the UI Page with a <script>https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script> tag, but I cannot call any jquery in UI Scripts linked to this UI Page, I get errors like "$ is not a function". (Could it be and issue with the namespace since I'm in a scoped application?).
Also I cannot load the User Interface jquery-ui.min.js in either the UI Page or the UI Script. I have tried loading it with a <script> tag at the top of the UI Page and by putting the <script> tag in a UI Macro and then doing a <g:macro_invoke> in the UI Page, but neither version worked.
Any help would be appreciated.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-25-2016 09:22 AM
Have you tried this -
<g:requires name="scripts/lib/jquery_includes.jsx" includes="true" />
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-25-2016 10:45 AM
Srikanth,
As far as I know <g:requires> is used to add existing UI Scripts to UI Macros or Pages, I was trying to avoid copying the source code for jquery and creating a UI script so I could call it.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-25-2016 09:29 AM
Sebastian,
When you look at the network tab or resources tab in Inspect Element, do you see the jQuery.js getting loaded? You may need to run jquery in noconflict mode, https://jylertones.com/blog/2013/05/the-right-way-to-use-jquery-with-servicenow/
Good luck!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-25-2016 10:47 AM
Andrew,
Seems to be loading OK, but I still get the error messages. I will try noconflict mode, thanks.