/
Configuring Shared JavaScript Libraries
Configuring Shared JavaScript Libraries
You can take all existing scripts of significant size and complexity and re-factor them into a JavaScript library. You can put the library reference into script files, and replace any existing inline blocks of code with calls to the library. For example, the Activity OnSave JavaScript file might change to something like the following:
<script type="text/javascript" language="javascript" src="ExampleActivity.js"></script><script type="text/javascript"> function onSave () { return oActivityHandler.onSave ( "Activity" /** vs. Attendee Call */, "SampleDrop|PromoItem|ProductDetailed" /* requires signature */, "SampleRequest" /* does not require signature **/,......); } </script>
Using JavaScript libraries allows you to eliminate code duplication and build JavaScript unit tests. If you decide to use JavaScript libraries, then note the following:
- You can enter scripts into the Swift MEAP™ Server. For more information, see "Uploading a JavaScript Library to the Server".
- You must keep the Event Handler within inline event scripts rather than the .js file.
You must change the script header to reference the specific library as follows:
<html><head><title>YOURPRODUCT</title> <script src="SwiftMEAP/callsampledrop.js" type="text/javascript" language="javascript"></script> <script type="text/javascript" language="javascript" src="callsampledrop.js"></ script> <script type="text/javascript"></script></head><body></body></html>
where:
- src is the location of the script library, relative to the subfolder
- type is always equal to "text/javascript"
- language is always equal to "javascript"
, multiple selections available,
Related content
Before Adding JavaScript Code
Before Adding JavaScript Code
More like this
Swift MEAP Configuration for External Application Support
Swift MEAP Configuration for External Application Support
More like this
SwiftMEAPJavaScript
SwiftMEAPJavaScript
More like this
About Actions with JSON
About Actions with JSON
More like this
Using JavaScript to Implement Quick Action and Custom Action Buttons
Using JavaScript to Implement Quick Action and Custom Action Buttons
More like this
JavaScript Structure Used in Swift MEAP
JavaScript Structure Used in Swift MEAP
More like this