La colección de la vista solo funciona en console.log
Perdón por el vago título, no estoy seguro de lo que está pasando lo suficiente como para formularlo mejor.
Por lo tanto, este es el render en mi opinión:
render: function () {
var that = this;
var template = JST['gists/index'];
that.$el.html(template);
console.log(['index to render', that.collection]);
_.each(that.collection, function (gist) { // <- I set a breakpoint here
console.log('looping');
that.appendGistDetail(gist);
});
return that;
},
El `console.log (..., that.collection]) está registrando esta colección correctamente:
["index to render", child]
0: "index to render"
1: child
_byId: Object
length: 1
models: Array[1] // <- Note one element. Saving space, but I checked it out and the model is correct
// Worth noting 'looping' is not being logged
Sin embargo, la salida de la variable Variable de alcance de punto de interrupción mencionada anteriormente en las herramientas Chrome Dev:
that: child
$el: jQuery.fn.jQuery.init[1]
childViews: Array[0]
cid: "view2"
collection: child
_byId: Object
length: 0
models: Array[0] // <- Note it's empty, just to test I also set a bp on the line above and it's the same, and when I hovered my mouse over `that.collection` from `console.log` it also said it was empty, but it logs correctly.
Entonces, no estoy realmente seguro de qué hacer, o incluso de lo que está pasando.