0
我的骨幹函數我想觸發一個條件方法,該函數已經在該對象內,在events
聲明中通過用戶點擊添加,這工作正常。但是,我的狀態點擊事件並不觸發..單擊事件不觸發
這裏是我的代碼:
在視圖部分:
events:{
"click .mainMenu a":"listTrigger" // this is work on user click
},
initialize:function(params){
_.bindAll(this);
var that = this;
this.listItems = ["projectName","assignedTo","projectName"];
this.classItems = ["projectName","assignedTo","sortBy"];
this.listCatch = [];this.boardCatch=[];
this.params = params,
this.filterState = false,
this.listTriggerElement = "";//i am initiating a element variable
for(var i=0;i<this.listItems.length; i+=1){
this.listCatch[i] = [];
}
this.collection = new singleton.collection;
// this.collection.on('reset', this.render);
this.collection.on('add', this.render);
this.collection.on('remove', this.render);
var dataFetcher = function(){
that.collection.fetch({update:true,remove:true});
appDataFetcher = setTimeout(dataFetcher,10000);
};
var appDataFetcher = setTimeout(dataFetcher,0);
},
render:function(){
this.listCollection = this.collection;
this.boardCollection = this.collection;
this.filterCollection = this.collection;
this.listCollect();
this.filterState != true ? this.boardViewSet() : this.listTriggerElement.trigger('click');
// checking by condition and triggering click.. not working
},
listTrigger:function(e){ //it should work by user click as well data udpate..
e.preventDefault();
this.listTriggerElement = $(e.target);
var filterKey = $(e.target).text();
var category = $(e.target).parents('ul').prop('class');
var collect = _.filter(this.filterCollection.models, function(model){
return model.get(category) === filterKey;
});
var newColl = new singleton.collection();
newColl.reset(collect);
this.boardCollection = newColl;
this.boardViewSet();
this.filterState = true;
}
我怎麼能解決這個問題..?
是的,類名上有一個範圍。我需要獲取類名並獲取數據.. – 3gwebtrain 2013-02-15 11:08:12
Stur是正確的,您需要指定el屬性,className也不適用於我 – 2013-02-17 02:20:37