In my current project, I am working with ROR, Backbone, Underscore JS and JQuery. In one of the view I set the JST template as follows
ABC.Views.BoardView = Backbone.View.extend({
template : changeBoard,
// el: '#boardHolder',
events : {
'click .count' : 'showPlaced',
'click #newCard' : 'newCardForm',
'click #showCardsOverview' : 'showCardsOverview'
},
it continues...
Also I have a function in the bottom of the page as follows
changeBoard: function(){
var params = window.location.search.replace( "?", "" );
var param= params.split("=");
var boardSize = param[1];
//return boardSize;
if(boardSize === 4){
'analysis/board44'
}else{
'analysis/board'
}
}
Why I wrote that function is to load different JST templates for taking the parameter from the URL. But this way is not working for me. It gives me the following error
ReferenceError: changeBoard is not defined
[Break On This Error]
template : changeBoard,
Does anyone know how to load dynamic JST template by getting the URL parameters
Thanks
Check this sample: template: null,
However, you can do the same in if statement in a function.. this.changeboard. Code will be something like: initialize: this.changeboard. Hope it helps. And not too late!!