mirror of
https://github.com/kbparagua/paloma
synced 2023-03-27 23:21:17 -04:00
Update README.md
This commit is contained in:
parent
5b660a99ab
commit
a9df7e1add
1 changed files with 46 additions and 0 deletions
46
README.md
46
README.md
|
@ -115,6 +115,52 @@ Paloma.controller('Articles', {
|
|||
});
|
||||
```
|
||||
|
||||
### Namespace
|
||||
|
||||
Namespaced controller should follow this format: `namespace/controller`.
|
||||
|
||||
Rails controller:
|
||||
```ruby
|
||||
class Admin::UsersController < ApplicationController
|
||||
def new
|
||||
@user = User.new
|
||||
end
|
||||
end
|
||||
```
|
||||
|
||||
Paloma controller:
|
||||
```js
|
||||
Paloma.controller('Admin/Users', {
|
||||
new: function(){
|
||||
// Handle new admin user
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
### Controller Inheritance
|
||||
|
||||
It is also possible to create a controller that is a subclass of an existing controller, using the following syntax:
|
||||
`Controller < ParentController`
|
||||
|
||||
```js
|
||||
Paloma.controller('Application', {
|
||||
index: function(){
|
||||
alert('Application: Index');
|
||||
},
|
||||
|
||||
new: function(){
|
||||
alert('Application: New');
|
||||
}
|
||||
});
|
||||
|
||||
Paloma.controller('Users < Application', {
|
||||
// Override Application's new action
|
||||
new: function(){
|
||||
alert('Users: New');
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
## Advanced Usage
|
||||
|
||||
You can manipulate what controller/action should Paloma execute by calling `js` method **before** rendering.
|
||||
|
|
Loading…
Reference in a new issue