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
8718284764
commit
8530fc2aaa
1 changed files with 24 additions and 0 deletions
24
README.md
24
README.md
|
|
@ -149,3 +149,27 @@ You can manipulate callback behavior by using the `js_callback` command before t
|
|||
|
||||
This will execute `clients/index` callback instead of `[controller]/index`.
|
||||
|
||||
Passing Parameters
|
||||
-
|
||||
You can also pass parameters to the callback by passing a `:params` key to `js_callback`. The passed parameters
|
||||
will be available on the callback by the `params` object.
|
||||
|
||||
**Example:**
|
||||
|
||||
`users_controller.rb`
|
||||
```ruby
|
||||
def destroy
|
||||
user = User.find params[:id]
|
||||
user.destroy
|
||||
|
||||
js_callback :params => {:user_id => params[:id]}
|
||||
end
|
||||
```
|
||||
|
||||
`/paloma/users/destroy.js`
|
||||
```javascript
|
||||
Paloma.callbacks['users/destroy'] = function(params){
|
||||
var id = params['user_id'];
|
||||
alert('User ' + id + ' deleted.');
|
||||
};
|
||||
```
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue