// do something here..
There is another fundamental problem with the code: its scope.
// From PHP
Extending The Universal library
The way this scope is implemented is quite similar to how jQuery plugins work. The purpose of univ() is to 'absorb' new functions through this syntax:
All you need to do now is to include this JS file
Including JS files
Agile Toolkit has 3 different ways to include your files. Open atk4/templates/shared/shared.html and find the "js_include" tag. When Agile Toolkit is rendering your page, it will place some includes in there.
Those includes will be loaded through AJAX and evaluated after they are loaded. Using them is extremely simple:
Again, thanks to Agile Toolkit, your code is portable, compact and works great.
If you are including some 3rd party code, they sometimes might not like dynamic loading. Third party code might assume that the on-ready is not yet triggered or do some other kind of magic. Google Maps code, for example, wants to be loaded along with your page.
If this happens, you can specifically instruct Agile Toolkit to put the include inside the HTML.
You must be mindful to include this on the page, which is loaded directly, and can potentially open other pages through AJAX, requiring this include. If unsure, add this code to your API's init() method.
If you want to go even more 'hardcore' with the include you can do this:
or even add include into shared.html file once you place it local template directory.
Executing any JS code
// SAFE: $my_message is escaped