Javascript programming in themes
Javascript code hierarchy is as follows:
- Surikata.io's Core Javascript API exposes methods for performing AJAX calls to the backend.
- A plugin can expose its own Javascript methods. This is optional for each plugin. An example is plugin WAI/Customer/Cart which exposes methods for manipulating shopping cart. These nethods use the Core API.
- Each theme uses the API of plugins used on the rendered page. An example is a page with detail of the product where button Add to cart uses an API of WAI/Customer/Cart plugin.
This hierarchy describes the diagram below.
Diagram generated by www.nomnoml.com
Before reading the chapters below, we recommend to get familiar with naming conventions for classes and objects. We developed them for better orientation in the code and faster learning curve.
Core Javascript API
Surikata.io's core Javascript API