Reputation: 1440
After some first steps with dojo I managed to have a var model;
and bind it to an input with dojo with
require(["dojo/parser"],
function (parser) {
model = { myValue:null };
parser.parse();
}
);
In my .jsp I have some input with data-dojo-props = "value: at(model, 'myValue')"
. The myValue
gets filled with the value from the input.
Now I tried to have that model inside an object.
function MyObject() {
var self = this;
this.model;
require(["dojo/parser"],
function (parser) {
self.model = { myValue:null };
parser.parse();
}
);
}
In my .jsp I have a myObject = new MyObject();
and the input changed to data-dojo-props = "value: at(self.model, 'myValue')"
(when I tried to write myObject.model
, dojo complained, that myObject
is undefined, so I guess the scope of the require/binding stuff is from where it is declared - so self.myValue
seems to be the right thing in data-dojo-props
).
My Problem: after I moved the model
inside MyObject
the values of the input won't bind to myValue
anymore.
What am I doing wrong - or is it even impossible what I'm trying to do?
Upvotes: 0
Views: 180
Reputation: 1440
Not far away ... - you have to tell dojo more explicitely where the model is - the way for me is to use the propsThis
argument in parser.parse()
.
function MyObject() {
var self = this;
this.model;
require(["dojo/parser"],
function (parser) {
self.model = { myValue:null };
parser.parse(propsThis: self);
}
);
}
And the input has a data-dojo-props = "value: at(this.model, 'myValue')"
.
Upvotes: 1