わかりました、オブジェクトの参照を関数に転送できるかどうか疑問に思っています。私が何を言おうとしているのか理解できない場合は、これが役立つかもしれません:
//so i declare the variable `Editor`
var Editor = new (function(e, d){
this.edit = e;
this.dyna = d;
this.old = ""; //and set these variables inside the object
this.update = function() {
var ta = $(Editor.edit)[0].value, dy = $(Editor.dyna)[0].contentDocument;
//what i want is to be able to refer to the variables (ie. "edit") without using "Editor."
if (Editor.old !== ta) {
$(dy).text(ta);
Editor.old = ta;
}
window.setTimeout(Editor.update, 150);
}
return this;
})("editor","dynamic");
したがって、更新機能については、次のようなことができるようにしたいと考えています。
this.update = function() {
var ta = $(edit)[0].value, dy = $(dyna)[0].contentDocument;
if (old !== ta) {
$(dy).text(ta);
old = ta;
}
window.setTimeout(update, 150);
}
そして、オブジェクトから変数 (edit、dyna、old) を取得しEditor
ます。ありがとう。