I’m not sure where to start with this, if someone could give me a pointer that would be great.
How do you work with the JS API within squiz matrix?
I created a JS API asset, how do I access it? (eg: which URL endpoint do I send the Ajax requests to? Can I have an example?)
http://<hostname>/?a=999999
Where do I source the JS API library from? I assume I need some URL to load that into the page before using it to instantiate the objects. Or is it loaded automagically?
You need to make sure the JS API asset is created somewhere where it receives a browserable URL. It’s basically a JavaScript file that you would request like any other JS files.
So if your JS API asset has a URL on it (check its web path screen), you should be able to just do:
<script src="./?a=1234">
</script>
<script>
var options = new Array();
options['key'] = '4767689380';
var js_api = new Squiz_Matrix_API(options);
<script>
The network tracing tool on the front-end should track it by the full file name, as the ./?a= will get replaced with an absolute URL. So just make sure you name the file asset hello.js as well and you should be able to track it easily on the front-end.
Hi
Matrix will replace urls in the format: src="./?a=354772"
With a webpath (as set in the webpaths section of the asset) or a /__data url for files if ‘Allow Unrestricted Access’ is set to Yes.
Alternatively you could also try using a keyword to set the URL: src="%globals_asset_url:354772%"
Also try adding a root node(s) for your JS API asset. The assets you want to do stuff with should be under one of these.