Hi, I am working on a website right now that use 1 controller that display a content manufactured by a widget controller. The Widget is called when you click on an element it works once but when you click again nothing is displayed. I think the controller is not executed the second time only the first. Can someone tell me how to avoid that kind of problem ? How to execute plenty of time this controller ?
- steal(
- '//models/personal_area.js',
- '//controllers/widgets/moments_list.js',
- '//controllers/widgets/followers.js',
- '//controllers/widgets/followings.js',
- function() {
- $.Controller('PersonalAreaController',{
- defaults : {
- userId : 0
- }
- },
- {
- init : function(el, opt) {
- PersonalArea.findAll({
- userId : opt.userId
- },
- function(models) {
- el.append('//views/personal_area.ejs', models);
- });
- },
- '#button_2 click' : function(el,ev) {
- var classP = "";
- classP = el.attr('class').substr(11);
- $(".moments_list").html('');
- $('#momentsList').moments_list({
- selectedCategoryId : classP,
- isNotClicked : [true, true, false, true, true],
- isDark : 2,
- areaInit : true,
- superInit : false
- });
- },
- });
- }
- );
- steal(
- '//controllers/modules/continuous_list.js',
- '//models/the_moments.js',
- '//controllers/widgets/moments.js',
- '//controllers/at_a_glance.js'
- ).then(function() {
- ContinuousListController('MomentsListController',{
- defaults : {
- params : {},
- DarkColor : [],
- clearColor : [],
- height : [40, 36, 32, 28, 28],
- template : '//views/moments_list.ejs',
- models : null,
- prevId : 0,
- userId : 0,
- init : true,
- triangleInit : true,
- selectedCategoryId : 'all',
- momentsBackUpCount : 0,
- momentsCount : 0,
- momentsLimit : 32,
- modelBackUp : [],
- category : [],
- isNotClicked : [true, true, true, true, true],
- isDark : 10,
- areaInit : false,
- superInit : true
-
- }
- },{
- init : function(el, opt) {
- var _this = this;
-
- this.load();
- this.options.params.prevId = this.options.prevId;
-
-
- if(this.options.superInit){
- this._super(); // ContinuousListController.init
- this.options.superInit = true
- }
- },
- load : function() {
- var _this = this;
- var models;
- TheMoments.findAllByTimeline(this.options.params, function(models) {
- _this.options.models = models;
- if(_this.options.momentsCount==0){
- _this.options.category = models.category;
- _this.options.modelBackUp = models;
- _this.options.momentsCount = models.length;
- }else{
- _this.options.momentsCount = models.length;
- _this.options.momentsBackUpCount = _this.options.modelBackUp.length;
- for(var i = 0; i < models.length; i++){
- _this.options.modelBackUp[_this.options.momentsCount+i] = models[i];
- }
- }
-
- _this.appendMomentsList();
- _this.categorySelect();
-
- });
- }, ...