AfterRender called twice with selector
Having issues with the after render and the resulting DOM element it generates.
HTML
<script src="http://ajax.microsoft.com/ajax/jquery.templates/beta1/jquery.tmpl.min.js"></script>
<script src="http://github.com/downloads/SteveSanderson/knockout/knockout-1.2.1.js"></script>
<script src="http://jcstuff.jcreamerlive.com/scripts/knockout.mapping.js"></script>
<div data-bind="foreach: stuff, afterRender: window.render">
<div data-bind="text: name + Date()"></div>
</div>
<button id="add">Add</button>
JavaScript
var viewModel = {
stuff: ko.observableArray([{ id : 1, name : 'Thing'},
{ id: 2, name : 'Thingier' },
{ id : 3, name : 'Thingiest' }])
};
window.render = function(el){
// This line does weird stuff!!
// Observe the console with and without it
// All I want to do is get my stuff...
var stuff = viewModel.stuff();
alert('Hi');
};
var update = function(){
console.log(viewModel);
viewModel.stuff.push({ id : 4, name : 'Thingiestest' });
};
$(function(){
ko.applyBindings(viewModel);
$("#add").click(function(){
update();
});
});