1
0
Fork 0
mirror of https://github.com/kbparagua/paloma synced 2023-03-27 23:21:17 -04:00

Update README.md

This commit is contained in:
Karl Bryan Paragua 2013-03-03 00:15:44 +08:00
parent 1271fba2a7
commit 538322574f

View file

@ -239,8 +239,8 @@ Paloma.callbacks['users']['destroy'] = function(params){
};
```
Locals
-
##Locals
Locals are variables or methods which can be made locally available within a controller or a namespace. Locals can also be made available throughout the whole Paloma files (globally).
The motivation of Locals is to organize helper methods and helper variables within a namespace or controller.
@ -263,8 +263,7 @@ The motivation of Locals is to organize helper methods and helper variables with
This contains methods and variables that are intended to be available on the specific controller only.
Creating A Local
-
###Creating Locals
Locals can be created using the `locals` object inside `_filters.js` file.
**Example:**
@ -277,8 +276,7 @@ locals.helperMethod = function(){
locals.helperVariable = "WOW!";
```
Using Locals
-
###Accessing Locals
Locals can be accessed in your filter and callback files using the `_l` object.
**Example**
@ -293,6 +291,18 @@ Paloma.callbacks['users']['new'] = function(params){
};
```
###Accessing Locals From Other Controller/Namespace
Sometimes there is a need to use other's local methods and variables.
You can achieve this by using the `Paloma.locals` object or its alias `_L`.
***Example***
```javascript
Paloma.callbacks['users']['new'] = function(params){
_L.otherController.helperMethod(); // accessing local helperMethod() of the otherController
_L.otherController.helperVariable;
}
```
Callback Chains
-
Callback chains are created after a redirect action. The chain will continue to increase its length until a render action is detected.