code_junkie

Ideas on making a javascript object name unique in ASP.Net?

Nov 13th, 2011
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. function MyObject( options )
  2. {
  3. this.x = options.x;
  4. }
  5.  
  6. MyObject.prototype.someFunction=function someFunctionF()
  7. {
  8. return this.x + 1;
  9. }
  10.  
  11. var opts = { x: 99 };
  12.  
  13. var myObject = new MyObject( opts );
  14.  
  15. function MyObject(options) { this.x = options.x; }
  16. MyObject.prototype.someFunction = function() { return this.x + 1; }
  17. MyObject.create(id, options) {
  18. if (!this._instances) this._instances = {};
  19. return this._instances[id] = new MyObject(options);
  20. }
  21. MyObject.getInstance(id) { return this._instances[id]; }
  22.  
  23. MyObject.create(ClientID, {x: 99});
  24.  
  25. String.Format("onclick="MyObject.getInstance('{0}').someFunction()", ClientID);
  26.  
  27. function MyObject( options ) { MyObject.x = options.x; }
  28. MyObject.x = 99; // static
  29. MyObject.prototype.someFunction = function () { return MyObject.x + 1; }
Add Comment
Please, Sign In to add comment