Workflow and ServiceDesk Community

 View Only
  • 1.  Reference External Javascript Library (jQuery) in Web Forms Project

    Posted Aug 15, 2013 07:03 PM

    Does anyone know how I can reference an external javascript library such as jQuery in a Web Forms project? (Workflow Solution 7.1 SP2)

    I read somewhere that you're not supposed to use <script></script> tags, so how would I reference an external javascript library such as jQuery? Normally I would add a script reference to the top of my script and then call the functions I need (Example below):


    <script type="text/javascript" src="http://[IntranetSite].com/Scripts/jquery.min.js"></script>
    <script type="text/javascript">

    function MyFunction() {
    //Do Something Cool
    }

    </script>


    Thanks.

    Loekee



  • 2.  RE: Reference External Javascript Library (jQuery) in Web Forms Project

    Posted Aug 16, 2013 09:23 AM

    Perhaps the easiest would be to edit the properties for your webform and go into the behavior tab. The body custom events lets you add a key-value pair that could run script on something like "onload" which could do what you need. There are other events, so you can probably find what you need. There is also a "script" section, but I've never used that myself, so I'm not positive when entries there are processed.



  • 3.  RE: Reference External Javascript Library (jQuery) in Web Forms Project

    Posted Oct 04, 2013 05:07 PM

    Thank you for the response, I tried this many times and have watched reecardo's videos regarding using javascript in a web forms project. I am able to get his examples working and use the "script" section to paste my javascript and then call functions via the various events like "onload", but I'm still not able to add a reference to an external javascript file using these methods.

    It looks like there may be a way to drop my javascript file in the directory "C:\Program Files\Altiris\Workflow\Shared\scripts\Infragistics\Scripts" or place it somewhere in "C:\Program Files\Altiris\Workflow\Shared\scripts" ("SymWebInclude" in IIS points to this path) but I'm not sure exactly where to place the javascript file and how to call one of it's functions from a Web Forms project.

    The article below describes something similar to what I'm trying to achieve. They are able to call a javascript function by name, and the external javascript file resides in the path "C:\Program Files\Altiris\Workflow\Shared\scripts\Infragistics\Scripts".

    https://www-secure.symantec.com/connect/forums/workflow-creating-dynamic-content-text-and-image

    I want to be able to add my own .js file(s) in the path above and call functions by name that reside in that file.

    Does anyone know how I can achieve this?

     

     

     



  • 4.  RE: Reference External Javascript Library (jQuery) in Web Forms Project
    Best Answer

    Posted Oct 07, 2013 08:24 AM

    You're not going to be able to reference it using <script type="text/javascript" src="http://[IntranetSite].com/Scripts/jquery.min.js"></script>. You'll have to load dynamically with javascript in the Script section michael.george mentioned.

    Check out the solution on this forum. http://stackoverflow.com/questions/950087/how-to-include-a-javascript-file-in-another-javascript-file. He explains how this is loaded asynchronously so depending on when you want to use jquery you may need to use the callback function pattern he described under "So what to do about it ?" section.