Hi there,
Thanks a lot for your help. I was able to get my application working with your blog. However, I had to do some hacking, not sure if it's caused by the IIS (5.1). Bascially, the callback arguments have their values reassigned to '3' for some reason. However, if were to interrogate this.argument, i.e. this._, it gave the correct value. So I hacked the code by assigning this._ back to _. Have you ever come across this problem? It would be nice to understand what's going on with the callback arguements.
Thanks,
yin
define(['jquery', 'underscore', 'backbone', 'views/tocServiceView', 'collections/layers', 'models/layer'], function($, _, Backbone, TOCServiceView, Layers, Layer){
_ = this._;
$ = this.$;
var TOCView = this.Backbone.View.extend({
template: _.template(this.$("#toc-template").html()),
initialize: function () {
_.bindAll (this, 'render');
this.render();
},
render: function(){
$("#mapTOC").empty ();
var currentView = this;
this.collection.each (function (service) {
//Insert Service Name
$("#mapTOC").append (currentView.template(service.toJSON()));
//Create a Layers collection for each service
var layers = new Layers ();
//Convert from layer array to Layer type
_.each (service.get ("Layers"), function (layer) {
var convertedLayer = new Layer (layer);
layers.add (convertedLayer);
});
//Create a TOCServiceView for each service
var tocServiceView = new TOCServiceView({
collection: layers
});
});
return this;
}
});
//Return MapView as a type
return TOCView;
});