Skip to content

4.09. Global JS

ArachnidsGrip edited this page Apr 15, 2019 · 1 revision

The GlobalJs class append a JSON object to the header.

<script id="weloquent_globaljs" type="text/javascript">
//<![CDATA[

var GJS = {...}

//]]>

</script>

It is accessible via GlobalJs facade.

API

GlobalJs::add($index, $data = null [, $toAdmin = false]);

GlobalJs::remove($index);

GlobalJs::update($index, $data = null [, $toAdmin = false]);

Examples

GlobalJs::add('foo', 'value 1');

GlobalJs::add('bar.baz', 'value 2', true); // admin only

# now you can access via JavaScript

GJS.foo // value 1

GJS.bar.baz // value 2

Clone this wiki locally