Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Bug:accessing tab after creating array called tasks

    Found a little problem while programming
    I have created an array called "tasks" inside of a transformResponse of a RestDataSource which will create some htmlpanes in a tab, when I want to access this tab I get following message from firebug:
    _1.$kk is not a function
    file:/C:/xampp/tomcat/webapps/smart/isomorphic/system/modules/ISC_Core.js
    Line 2510

    when I give the array a different name like foo, it works perfekt.

    I have tried it in Firefox 3 and ie6

    here is my code:

    Code:
    isc.RestDataSource.create({
        ID:"DSTasks",
        fields:{
            id:{title:"id", name:"id", hidden:true},
            name:{title:"Bezeichnung", name:"name"},
            added:{title:"hinzugefügt", name:"added"},
            due:{title:"fällig am ", name:"due"},
            status:{title:"status", name:"status"}
            },
        dataFormat:"json",
        dataURL:"test2.json",
        transformResponse : function (dsResponse, dsRequest, jsonData) {
            rows = isc.XMLTools.selectObjects(jsonData, "/response/rows");
    		tasks=new Array(rows);
    		notes=new Array(rows);
    		assigned=new Array(rows);
    		dates=new Array(rows);
    		for (u=0; u<=rows; u++) {
    			tasks[u-1]=isc.XMLTools.selectObjects(jsonData, "/response/data/"+u+"/tasks");
    			notes[u-1]=isc.XMLTools.selectObjects(jsonData, "/response/data/"+u+"/note");
    			assigned[u-1]=isc.XMLTools.selectObjects(jsonData, "/response/data/"+u+"/assigned");
    			dates[u-1]=isc.XMLTools.selectObjects(jsonData, "/response/data/"+u+"/date");
    		}
    		drawTasks();
    	}
    })
    isc.DynamicForm.create({
            ID:"FormSearch",
            canFocus:true,
            fields:[
                {name:"search", title:"Suche", canFocus:true,type:"text",keyUp: 
    			function() {
    				var bla=FormSearch.getValue("search");
    				for(i=0;i<tasks.length;i++){
    					if(bla>"")  {
    						if(tasks[i].toString().toLowerCase().search(bla.toLowerCase())>0 ) {
    							VlTasks.getMember("pane"+tasks[i]).show();
    						}	 
    						if(tasks[i].toString().toLowerCase().search(bla.toLowerCase())<0  ) {
    							VlTasks.getMember("pane"+tasks[i]).hide();
    						}		 
    					}else {
    						VlTasks.getMember("pane"+tasks[i]).show();
    					}
    				}
    				
    			}
    		},
            ]
    })
    
    isc.VLayout.create({
        ID:"VlTasks",
        padding:20
    })
    isc.HLayout.create({
        ID:"HlTasks",
        members:[FormSearch,VlTasks]
    })
    isc.HTMLPane.create({
        ID:"functions",
        contents:"<a href=\"javascript:DSTasks.fetchData()\">laden</a>"
    })
    isc.TabSet.create({
        ID:"TabSetProjects",
        width:"100%",
        height:"100%",
        tabs:[
            {ID:"overview", title:"Übersicht",pane:functions},
            {ID:"tasks", title:"Aufgaben", pane:HlTasks},
            {ID:"milestones", title:"Meilensteine"},
            {ID:"files", title:"Dateien"},
            {ID:"messages", title:"Nachrichten"}
        ]
        
    })
    function drawTasks() {
    	for(var z=0; z<tasks.length;z++)
    	{
    		var panename="pane"+tasks[z];
    		VlTasks.addMember(
                isc.HTMLPane.create({
                    ID:panename,
                    width:"100%",
                    height:40,
                    overflow:"hidden",
                    animateTime:200,
                    border:"1px solid black",
                    contents:"<div id=\"test\"><a href=\"javascript:changeStatus("+panename+")>"+tasks[z]+"</a></div><br> zugeteilt: "+assigned[z]+" fällig am: "+dates[z]
                })
            );
            if(u!=tasks.length){
                VlTasks.addMember(
                    isc.HTMLPane.create({
                    width:"100%",
                    height:10,
                    overflow:"hidden"
                        })
                    );  
                }
    	}
    }
    Hit "laden" in the first tab and then go to the second called "Aufgaben"

    Chris

    PS:Please release 7.0 before trying to fix this ;-)

    #2
    Hi Chris,

    If you've definitely tracked this down to the variable having the name "tasks", then I suspect some browser toolbar or similar Firefox extension you are using has created a global variable called that - SmartClient has no "tasks" variable and the code is run through a scanner that ensures that globals are never created.

    Because of this kind of issue we recommend putting all your globals on a global "application object" instead of directly in global scope. For example:

    Code:
    window.myApp = isc.Class.create();
    myApp.tasks = [ ... ];

    Comment


      #3
      Well, i have tracked it down to this variable and it doesn't work in firefox AND internet explorer. I don't have any extensions or toolbars in ie.

      Thanks for your advice with the object, will use this instead

      Chris

      Comment


        #4
        Hmm, tried out your code, but no luck reproducing the error. It's a mystery what's different about your system (maybe some kind pre-installed utility on your machine that includes browser plugins), but, that practice of keeping your globals on an "application object" will avoid this and any similar globals collisions.

        Comment

        Working...
        X