How do I include a script include into a ui page?

mahudg2
Kilo Expert

I'm making a ui page and attempting to include jquery, as well as responsive slides (a plugin for jquery). To do so I created two 'script includes' that contained the contents of jquery as well as the responsive slides plugin. I just want to include these scripts, but to be honest I have no idea how to. I attempted to read the wiki about them Script Includes - ServiceNow Wiki but to be honest it just left me clueless. Does anyone have any ideas?

 

Thanks in advance!

1 ACCEPTED SOLUTION

<script> should work. I've used it many times.


Or you could use either of the two jelly versions:



UI Scripts use:


<g:include_script src="rslides.jsdbx" />



or for UI Macros   use:



<g:rslides />


or if that doesn't work:


<g:macro_invoke macro="rslides" />



Also, it would be nice if you can expand on how it didn't work. Aside from not seeing what you want to see visually happen, what checks did you make to see if the script is actually being included in the page.


For example one check I always do is to bring up that page and do an "Inspect Element" and use the resources tab to see if the the script actually made it to the page. (Chrome or FF; not sure if you can do the same in IE)



Chris Burks


Implementations Technician


Efficient Technology


View solution in original post

13 REPLIES 13

eican
Kilo Guru

I'd say the same way as you perform an Asynchronous GlideAjax call. Just have the script in the Script Include and make sure the checkbox "Client callable" is set and you should be able to call any function contained in the script include.


You can also filter the existing Script Includes where Client callable=true and you will find many examples where you can check in a next step the UI Pages how it was implemented.


Hmm, excuse my ignorance, but that just confuses me even more. I realized I might of going about it the wrong way, so I went ahead and created a UI script instead.



I have a UI script named rslides and I'm trying to include it in a UI page with the following


<script>


But that isn't working. Am I going about it the wrong way?


Sounds right. You can compare with the out-of-box implementation of CoolClock - does also a combination of what you are doing.


Unfortunately <script> didn't work. I suppose I have a bigger problem than I realized