the html
<input type="text" value="teste" id="1" />
the javascript
function classe() {
this.nome = "rodrigo";
this.setup = function() {
var ref = this;
$("#1").keydown(function (event) {
if (event.keyCode == 13) {
$(this).attr("value", ref.nome);
}
})
}
}
var obj = new classe();
obj.setup();
I was wondering if is possible to pass this into the nested function without having to save it to a local variable ref inside the parent function.
test code on: http://jsfiddle.net/7zorgou0/1/
var ref = thisline abovethis.setup = functionfunction(){}.bind(this)method)