javascript - jquery: context with closures? -
I have a simple question about jQuery about the general question, but javascript approach also ...
< P> Is it okay to do this? : this._checkedTexts.length = 0; // & lt; Arax - related to "Mary" reference. $ ('# ValueContainer Input: Check'). Each (function () {contextCheckedTexts.push ($ (this) .text ());});
Since 'this' indicates the element, I am using one stop here to keep additional context for each 'handler'.
Is this the way
What are the other options?
I think any risks may be involved in how this is done or how to stop using it in this way? It is very practical - but I am always concerned about starting reference-problems, when using the closure - which is hard to find later.
I do not know what you are trying to achieve, but your code can do the same. Are,
this._checkedTexts.length = 0; // & lt; - Aram related to "me" var arr = $ ('# valueContainer input: check') Map (function () {return $ (this) .text ();}) Get (); This._checkedTexts = this._checkedTexts.concat (arr);
Comments
Post a Comment