jquery - Giving Namespace in javascript file when a assignment statement is present -
i have piece of javascript code want add namespace. in code there assignment operation taking place outside functions. please tell me how put in namespace? code given below.
var mynamespace={ canvaspanel:{}, stage:{}, someshape:{}, drawlinegraph:function(datalist,color,basey) { //create shape this.datalist=datalist; this.index=0; this.currentday=1; }, mynamespace.drawlinegraph.prototype = new createjs.shape(); //getting problem here mynamespace.drawlinegraph.prototype.constructor = drawlinegraph; //getting problem here** , drawlegend:function(){ } };
you can wrap function , subsequent assignments in function, call immediately, this:
drawlinegraph: (function() { var f = function(datalist, color, basey { // create shape ... function code ... }; f.prototype = new createjs.shape(); ... more assignments ... return f; // assigned drawlinegraph })(),
Comments
Post a Comment