Skip to content

Commit 8cca4b4

Browse files
committed
Merge pull request #138 from fieg/load-event
Added load event object instead of scalar url as argument
2 parents 0cdc2f4 + a690dd7 commit 8cca4b4

File tree

8 files changed

+62
-11
lines changed

8 files changed

+62
-11
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
Changelog
22
=========
33

4+
## 2.1.1
5+
6+
* Changed argument of `load` event from url to event object
7+
* Fixed `prev()` return value
8+
49
## 2.1.0
510

611
* Added History extension

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
Infinite Ajax Scroll 2
2-
======================
1+
Infinite Ajax Scroll
2+
====================
33

44
A jQuery plugin to turn your paginated pages into infinite scrolling pages with ease.
55

bower.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"name": "jquery-ias",
3-
"version": "2.1.0",
3+
"version": "2.1.1",
44
"homepage": "http://infiniteajaxscroll.com",
5-
"main": "src/jquery.ias.js",
5+
"main": "src/jquery-ias.js",
66
"ignore": [
77
"**/.*",
88
"node_modules",

ias.jquery.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "ias",
33
"title": "Infinite Ajax Scroll",
44
"description": "jQuery plugin that progressively enhances your server-side pagination",
5-
"version": "2.1.0",
5+
"version": "2.1.1",
66
"homepage": "http://infiniteajaxscroll.com",
77
"download": "http://infiniteajaxscroll.com/download.html",
88
"docs": "http://infiniteajaxscroll.com/docs/getting-started.html",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "jquery-ias",
33
"title": "Infinite Ajax Scroll",
4-
"version": "2.1.0",
4+
"version": "2.1.1",
55
"description": "A jQuery plugin that turns your server-side pagination into an infinite scrolling one using AJAX",
66
"homepage": "http://infiniteajaxscroll.com",
77
"main": "src/jquery-ias.js",

src/jquery-ias.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Infinite Ajax Scroll v2.1.0
2+
* Infinite Ajax Scroll v2.1.1
33
* A jQuery plugin for infinite scrolling
44
* http://infiniteajaxscroll.com
55
*
@@ -171,9 +171,13 @@
171171

172172
delay = delay || this.defaultDelay;
173173

174-
self.fire('load', [url]);
174+
var loadEvent = {
175+
url: url
176+
};
177+
178+
self.fire('load', [loadEvent]);
175179

176-
return $.get(url, null, $.proxy(function(data) {
180+
return $.get(loadEvent.url, null, $.proxy(function(data) {
177181
$itemContainer = $(this.itemsContainerSelector, data).eq(0);
178182
if (0 === $itemContainer.length) {
179183
$itemContainer = $(data).filter(this.itemsContainerSelector).eq(0);

test/02-listeners-test.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,38 @@ describe("IAS", function () {
4444
return deferred.promise;
4545
});
4646

47+
it("should allow url to be changed in load event", function() {
48+
var deferred = when.defer();
49+
50+
jQuery.ias({
51+
container : '.listing',
52+
item: '.post',
53+
pagination: '.navigation',
54+
next: '.next-posts a'
55+
});
56+
57+
// first listener changes the url
58+
jQuery.ias().on('load', function (loadEvent) {
59+
// assert that it isn't already there
60+
buster.refute.contains(loadEvent.url, "ajax=1");
61+
62+
loadEvent.url = loadEvent.url + "?ajax=1";
63+
});
64+
65+
// second listener asserts the url is changed
66+
jQuery.ias().on('load', function (loadEvent) {
67+
buster.assert.contains(loadEvent.url, "ajax=1");
68+
});
69+
70+
scrollDown().then(function() {
71+
wait(2000).then(function() {
72+
deferred.resolve();
73+
});
74+
});
75+
76+
return deferred.promise;
77+
});
78+
4779
it("should call render listeners when render is complete", function() {
4880
var deferred = when.defer();
4981
var spy1 = this.spy();

test/buster.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
1-
var config = module.exports;
1+
var config = module.exports,
2+
fs = require('fs'),
3+
bower = {
4+
jquery: {
5+
main: 'jquery.js'
6+
}
7+
};
8+
9+
if (fs.existsSync('bower_components/jquery/bower.json')) {
10+
bower.jquery = JSON.parse(fs.readFileSync('bower_components/jquery/bower.json', 'utf8'))
11+
}
212

313
config["My tests"] = {
414
rootPath: "../",
515
environment: "browser", // or "node"
616
libs: [
7-
"bower_components/jquery/jquery.min.js"
17+
"bower_components/jquery/" + bower.jquery.main.replace(/^\.\//, ''),
818
],
919
sources: [
1020
"src/callbacks.js",

0 commit comments

Comments
 (0)