Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
explain how to add xhr option
  • Loading branch information
catmando authored and elia committed Jul 31, 2015
1 parent 1fb1fce commit dc644be
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,24 @@ request.errback { |response|
}
```

### Supplying an XHR method

To supply an XHR callback include a lambda with the `xhr` option:

```ruby
update_progress = lambda do
xhr = `new window.XMLHttpRequest()`
update_progress = lambda do |evt|
# update your progress here
end
`xhr.upload.addEventListener("progress", update_progress, false)`
xhr
end

cloud_xfer = HTTP.put "http://my.cloud.storage/location", xhr: update_progress, ... etc ...
```


## Usage of JQuery plugins
Extra plugins used for JQuery aren't available to ruby code by default, you will have to `expose` these functions to opal-jquery.

Expand All @@ -314,6 +332,7 @@ el = Element['.html_element']
el.cool_plugin({argument: 'value', argument1: 1000}.to_n)
```


## License

(The MIT License)
Expand Down

0 comments on commit dc644be

Please sign in to comment.