Last active
December 18, 2015 03:58
-
-
Save harboe/5721731 to your computer and use it in GitHub Desktop.
Knockout ObservableArray Map. Snippet from: Ryan Niemeyer - Getting the Most Out of Knockout.js @ http://vimeo.com/51103092
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 (undefined) { | |
// | |
// simple map function to extend the observableArray. | |
ko.observableArray.fn.map = function (data, Constructor) { | |
var mapped = ko.utils.arrayMap(data, function (item) { | |
return new Constructor(item); | |
}); | |
this(mapped); | |
return this; | |
}; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment