Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jkotchoff/Alloy-PullToRefresh-Example
Example implementation of https://github.com/cornflakesuperstar/Alloy-PullToRefresh using a ListView Collection
https://github.com/jkotchoff/Alloy-PullToRefresh-Example
Last synced: 4 months ago
JSON representation
Example implementation of https://github.com/cornflakesuperstar/Alloy-PullToRefresh using a ListView Collection
- Host: GitHub
- URL: https://github.com/jkotchoff/Alloy-PullToRefresh-Example
- Owner: jkotchoff
- License: other
- Created: 2014-10-28T19:39:20.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2014-10-29T02:13:42.000Z (over 10 years ago)
- Last Synced: 2024-08-02T14:07:56.376Z (7 months ago)
- Language: JavaScript
- Size: 11.4 MB
- Stars: 4
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.txt
- License: LICENSE
Awesome Lists containing this project
README
# Alloy *Pull to Refresh* Widget Example [](http://www.appcelerator.com/titanium/) [](http://www.appcelerator.com/alloy/)
## Overview
This *Pull to Refresh* implementation in Titanium Alloy features [ListView collection binding](https://github.com/cornflakesuperstar/Alloy-PullToRefresh-Example/commit/764e17e697a4f675478a0946bcfc3ecc96e7c50f) which is mostly based on:
[FokkeZB's Infinite Scroll widget - Test](https://github.com/FokkeZB/nl.fokkezb.infiniteScroll/tree/test)It is mostly based on:
[Jolicode's Alloy-PullToRefresh widget](https://github.com/jolicode/Alloy-PullToRefresh)
however it uses the:
[cornflakesuperstar Alloy-PullToRefresh Fork](https://github.com/cornflakesuperstar/Alloy-PullToRefresh)in order to be able to build the ListView for the Pull to Refresh widget in the [same alloy view](https://github.com/cornflakesuperstar/Alloy-PullToRefresh-Example/blob/master/app/views/index.xml) as the widget itself
ie.
* Define the widget and the *ListView* in a view:
```xml
```* Bind the refresh functionality in the controller:
```javascript
var listTopOffset = 20;
var refreshFn = function(){
$.listCollection.fetch({
success: function(collection) {
console.log("data retrieved");
$.pulltorefresh.stop(collection.models.length * 240, 20);
},
error: function(model, message){
alert("data fetch error: " + message);
$.pulltorefresh.stop(0, listTopOffset);
}
});
};var list = $.list;
if(OS_ANDROID){
$.index.remove(list);
}$.index.addEventListener("open", function(){
$.pulltorefresh.initialize({
control: list,
onRelease: refreshFn,
headerPullView: {
lastUpdate: {
width: '230dp'
}
}
});
refreshFn();
});$.index.open();
```