This page is a first draft, which will be revised and improved. Please leave us a note on the community page regarding any issue.
@include - How to Include Code From Other Sources
in many different situation, you would want to include external code in you app.
For example, let’s say you want to have the jGrowl notifications in your app.
All you need to do is to include the JS and CSS of the jQuery plugin:
@include "http://stanlemon.net/javascript/jquery.jgrowl.js"
@include "http://stanlemon.net/stylesheet/jquery.jgrowl.css"
and then call it from your app code:
$jquery.jGrowl("Hello World", {sticky : true});
Notes:
- @include statement must start at the first char on its line (no spaces, tab, etc. before)
- As the @include statement is specific Crossrider statement and not JS line, @include lines should not end in with a semi-colon
Behind the scenes
@include for CSS files will simply create a style tag, get the contents of the file and add it to that tag,
while @inlcude for JS files is the same as copy/pasting the external code to the beginning of your app’s code.
Please note that no matter where you put the @include in your code it will always be executed first.
Using includes when exposing your appAPI to your domain
When you expose the appAPI to your page (see Exposing appAPI section), you sometimes want to use the same @include you have already included in you appAPI.
To do so, you will need to declare it for each @include.
@include "http://stanlemon.net/javascript/jquery.jgrowl.js" iframe
@include "http://stanlemon.net/stylesheet/jquery.jgrowl.css" iframe
Note: The iframe parameter is optional, and will work only when exposing the sync appAPI version (supported in Firefox and Internet Explorer) and is ignored when exposing AsyncAPI (supported in Chrome, Firefox and IE).
what is a dom_worker? I can't find any explain in the wiki, nor in the demo apps. But sounds interesting.
I have removed the section from this wiki page as dom_workers and bg_workers are no longer supported.
Instead of workers you can use the App's Background code to run "timed tasks" using setTimeout and setInterval.
http://stanlemon.net/javascript/jquery.jgrowl.js and http://stanlemon.net/stylesheet/jquery.jgrowl.css
Aren't available anymore.