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

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -