Created
January 24, 2012 01:45
-
-
Save msarchet/1667273 to your computer and use it in GitHub Desktop.
streamfire
This file contains 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
function streamInfo(stream) { | |
var self = this; | |
self.name = stream.name; | |
}; | |
function getStream(streamName){ | |
return [{name: streamName}]; | |
} | |
function getStreams(){ | |
var streams = ko.observableArray(); | |
streams.push(new streamInfo()); | |
streams.push(new StreamInfo(getStream("Day9Tv"))); | |
return streams; | |
} | |
function StreamViewModel() { | |
var self = this; | |
self.streams = [{name: "LiquidRet"},{name: "Day9Tv"}]; | |
self.favoriteStreams = ko.observableArray(new StreamInfo(self.streams[0])); | |
self.addFavorite = function(streamName) { | |
self.FavoriteStreams.push(new StreamInfo(getStream(streamName))); | |
}; | |
}; | |
ko.applyBindings(new StreamViewModel()); | |
<h2>Your Streams</h2> | |
<div data-bind="text: favoriteStreams.length"></div> | |
<table data-bind="visible: favoriteStreams.length() > 2"> | |
<thead> | |
<tr> | |
<th>Stream</th> | |
<th>Favorite</th> | |
</tr> | |
</thead> | |
<tbody data-bind='foreach: favoriteStreams'> | |
<tr> | |
<td data-bind='text: name'></td> | |
</tr> | |
</tbody> | |
</table> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment