Skip to content

Commit b6ea1cd

Browse files
committed
small tweaks
1 parent 7ea0020 commit b6ea1cd

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

doc/events.md

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,25 +20,35 @@ Triggered when a new page is about to be loaded from the server.
2020

2121
The load event object contains the following properties.
2222

23-
| property | type | description |
24-
|-----------|---------------|-------------------------|
25-
| event.url | string | url that will be loaded |
23+
| property | type | description |
24+
|-------------------|--------|--------------------------------------------------------------------------------|
25+
| event.url | string | url that will be loaded |
26+
| event.ajaxOptions | object | options that are passed to [$.ajax method](http://api.jquery.com/jquery.ajax/) |
2627

27-
Using this event it is possible to change the requested url. This can be useful to append an arbitrary parameter to the requested url so the server can handle the request differently. For example to optimize the returned url by stripping everything outside the container element (header, footer, etc.). Because it is used as the settings object in $.get, you can also use this for more exotic configuration.
28+
Using this event it is possible to change the requested url. This can be useful to append an arbitrary parameter to the requested url so the server can handle the request differently. For example to optimize the returned url by stripping everything outside the container element (header, footer, etc.).
2829

2930
```javascript
3031
ias.on('load', function(event) {
3132
event.url = event.url + "?ajax=1";
33+
3234
// alternatively...
33-
event.data = { ajax: 1 };
35+
event.ajaxOptions.data = { ajax: 1 };
36+
})
37+
```
38+
39+
The ajaxOptions property can also be used for more exotic configurations.
3440

35-
// And as a more exotic example, timeout and HTTP auth
41+
```javascript
42+
ias.on('load', function(event) {
43+
// A more exotic example, timeout and HTTP auth
3644
event.timeout = 7000; //ms
3745
event.username = 'shirley';
3846
event.password = 'temple';
3947
})
4048
```
4149

50+
See http://api.jquery.com/jquery.ajax/ for a complete list of options.
51+
4252
### loaded
4353

4454
| argument | type | description |

src/jquery-ias.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,9 @@
183183

184184
var loadEvent = {
185185
url: url,
186-
dataType: 'html'
186+
ajaxOptions: {
187+
dataType: 'html'
188+
}
187189
};
188190

189191
self.fire('load', [loadEvent]);
@@ -213,7 +215,8 @@
213215
}
214216
}
215217
}
216-
this.jsXhr = $.ajax(loadEvent)
218+
219+
this.jsXhr = $.ajax(loadEvent.url, loadEvent.ajaxOptions)
217220
.done($.proxy(xhrDoneCallback, self));
218221

219222
return this.jsXhr;

0 commit comments

Comments
 (0)