module.js | |
NinjsModule | A NinjsModule is an object which encapsulates a certain behavior or functionality. |
Variables | |
data | The module’s data object |
name | The module’s name (string) |
run_tests (beta) | Boolean to turn tests on/off |
tests (beta) | Array of test files to run |
Functions | |
actions | The actions method contains code to be executed when run is called. |
run | Waits for the DOM to load then calls execute. |
call_on_ready | Waits for the DOM to be ready and then executes a callback. |
execute | Wrapper method that set’s up the environment and then calls actions. |
elements | Method to define module elements. |
set_data | Adds properties to the module’s data object. |
add_test | Adds a test file to the tests array (beta). |
_run_tests | Runs the test files in the test array. |
A NinjsModule is an object which encapsulates a certain behavior or functionality.
name | the name of the module |
Variables | |
data | The module’s data object |
name | The module’s name (string) |
run_tests (beta) | Boolean to turn tests on/off |
tests (beta) | Array of test files to run |
Functions | |
actions | The actions method contains code to be executed when run is called. |
run | Waits for the DOM to load then calls execute. |
call_on_ready | Waits for the DOM to be ready and then executes a callback. |
execute | Wrapper method that set’s up the environment and then calls actions. |
elements | Method to define module elements. |
set_data | Adds properties to the module’s data object. |
add_test | Adds a test file to the tests array (beta). |
_run_tests | Runs the test files in the test array. |
Adds properties to the module’s data object.
key | string or object (if string = key, if object sets multiple properties) |
value | value of key if key is string |
MyModule.set_data('some_key', 'some_value'); MyModule.data.some_key === 'some_value'
MyModule.set_data({ 'property_one': 'value_one', 'property_two': 'value_two' }); MyModule.data.property_one === 'value_one' MyModule.data.property_two === 'value_two'
The module’s data object
this.data
The module’s name (string)
this.name
Boolean to turn tests on/off
this.run_tests
Array of test files to run
this.tests