Skip to content

Commit 4566d9d

Browse files
committed
Add filtering/searching to remote slideshow example
1 parent 6ff20e2 commit 4566d9d

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

grid-spf/photoslideshow_remote.html

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
format: "json",
4242
api_key: "d86848d57cb3f7ad94f2ee9a3c90eff1",
4343
method: "flickr.photos.search",
44-
tags: "jquery",
44+
tags: filter[0].filterValue,
4545
sort: "relevance",
4646
per_page: take,
4747
page: skip
@@ -50,19 +50,28 @@
5050
resultsFilter: function (data) {
5151
this.totalCount = data.photos.total;
5252
return $.map( data.photos.photo, function( photo ) {
53-
console.log(photo)
5453
return {
5554
src: kite( "http://farm{{farm}}.static.flickr.com/{{server}}/{{id}}_{{secret}}_m.jpg", photo ),
5655
href: kite( "http://www.flickr.com/photos/{{owner}}/{{id}}/", photo )
5756
}
5857
});
5958
}
6059
});
60+
datasource.option("filter", {
61+
property: "tags",
62+
value: "jquery"
63+
})
6164

6265
$( "#slideshow" ).slideshow({
6366
source: datasource
6467
});
6568

69+
$( "#filter" ).change(function() {
70+
datasource.option("filter", {
71+
property: "tags",
72+
value: $(this).val()
73+
}).refresh();
74+
});
6675
$( "#page-size" ).change(function() {
6776
datasource.option("paging", {
6877
take: +$(this).val(),
@@ -81,7 +90,13 @@ <h1>Photo Slideshow</h1>
8190

8291
<hr>
8392

84-
Per page: <input id="page-size" value="2">
93+
<p>
94+
Per page: <input id="page-size" value="2">
95+
</p>
96+
<p>
97+
Tags to look for (comma seperated): <input id="filter" value="jquery">
98+
</p>
99+
85100

86101
<div id="slideshow"></div>
87102

0 commit comments

Comments
 (0)