Created
February 16, 2013 21:21
-
-
Save viezel/4968784 to your computer and use it in GitHub Desktop.
Alloy bug: Global collection is overriding others?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var collection = Alloy.Collections.collection; | |
var openAddItem = function(){ | |
var win = Alloy.createController("CollectionDetail").getView(); | |
win.open(); | |
} | |
function dataTransform(model) { | |
var transform = model.toJSON(); | |
transform.title = transform.first + " " + transform.last; | |
return transform; | |
} | |
//init - get the data | |
collection.fetch(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Alloy> | |
<Collection src="collection"/> | |
<Window id="win"> | |
<RightNavButton> | |
<Button onClick="openAddItem">Add</Button> | |
</RightNavButton> | |
<SearchBar id="search" /> | |
<TableView id="table" dataCollection="collection" dataTransform="dataTransform"> | |
<TableViewRow class="row" model="{id}" > | |
<Label id="titlel" class="rowTitle" text="{name}"/> | |
</TableViewRow> | |
</TableView | |
</Window> | |
</Alloy> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Alloy> | |
<TabGroup id="tabgroup"> | |
<Tab id="tab1" title="Tips"> | |
<Require src="Tips" id="tipsWindow" title="Tips"/> | |
</Tab> | |
<Tab id="tab2" title="Collections"> | |
<Require src="Collections" id="MyCollections" title="My Collections"/> | |
</Tab> | |
</TabGroup> | |
</Alloy> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var tipCollection = Alloy.Collections.tip; | |
var openAddItem = function(){ | |
var window = Alloy.createController("TipDetail").getView(); | |
window.open(); | |
} | |
$.win.addEventListener('close', function() { | |
// destroy global collection/model for our bindings - memory leaks. | |
$.destroy(); | |
}); | |
//sorting by date | |
tipCollection.comparator = function(entry1, entry2) { | |
return entry1.get('modifiedDate') > entry2.get('modifiedDate') ? -1 : 1; | |
} | |
//DATA transform of tableView | |
function dataTransform(model) { | |
var transform = model.toJSON(); | |
transform.modifiedDate = moment(transform.modifiedDate,'YYYY-MM-DD HH:mm:ss').fromNow(); | |
transform.city = transform.city + ", " + transform.country; | |
return transform; | |
} | |
var refresh = function(){ | |
// update data from remote | |
tipCollection.fetch(); | |
} | |
//init - get the data | |
tipCollection.fetch(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Alloy> | |
<Collection src="tip"/> | |
<Window id="win"> | |
<LeftNavButton> | |
<Button onClick="refresh">Refresh</Button> | |
</LeftNavButton> | |
<SearchBar id="search" /> | |
<TableView id="table" dataCollection="tip" dataTransform="dataTransform"> | |
<TableViewRow class="row" model="{id}" > | |
<Label id="titlelabel" class="rowTitle" text="{name}"/> | |
<Label class="rowSubTitle" text="{city}"/> | |
<Label class="dateLabel" text="{modifiedDate}"/> | |
</TableViewRow> | |
</TableView> | |
</Window> | |
</Alloy> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Any solutions to this issue yet? I'm kind of stuck with the same problem