oop - jQuery class is statically sharing an object across class instances -
Some time ago, I needed to create an object-oriented client using jQuery. I turned on to use the correct class solution.
Press a problem with it. When I define a global option object, I feel that the latter is shared in the classes I have confirmed that after editing the object in only one class, different code.log's printing code looks like this:
var MyClass = Class.extend ({default: {Distance: 10, speed: 20}, option: zero, init: function (option) {this.options = $. Extension (this .defaults, options);}, ...}); I need a global hash or array so that I can easily pass alternate settings in the classroom. What is the way to do this? If I do not have any work, I may have to resort to manual sets in class.
I am not sure that the option object is being shared instantly with the 'new' keyword through different class objects.
UPDATE
Do you need it?
var myObject = function () {var defaults = {speed: 20, distance: 10}; Var Option = Faucet; Return {init: function () {...}, setSpeed: function (speed) {this.defaults ['speed'] = speed; }, // etc}} and then call it like this:
myObject.init (); or
myObject.setSpeed (100); Maybe I do not understand this problem properly and I just need stfu
ps - above code is not directly tested from memory and
Comments
Post a Comment