What\'s the best way to access my this.rules variable from within $.each()? Any explanation of why/how would also be helpful!
app.Style = function(node) {
th
Store a reference to this
-- name it self
, for example --, before calling .each()
, and then access rules
using self.rules
:
app.Style = function(node) {
this.style = node;
this.rules = [];
var ruleHolder = node.find('Rule');
var self = this;
$.each(ruleHolder, function(index, value) {
var myRule = new app.Rule($(ruleHolder[index]));
self.rules.push(myRule);
});
console.log(this.rules)
}