I can create a zone, but when I try to use 'placeInZone', the code crashes.
This code in legacy style works just fine.
Here is my code in the setup function of my game:
// test the zone code in es6 land
// const [zone] = await importDojoLibs(['ebg/zone']);
document.getElementById(`mr_main`).insertAdjacentHTML('beforeend', `
<div id="testZone" style="width:100px; height:100px;border:1px black solid" ></div>
`);
this.testZone = new ebg.zone();
this.testZone.create(this, `testZone`, 100, 100);
this.testZone.setPattern('grid');
this.testZone.placeInZone('mr_disc_5_4_wrapper');
It throws:
Uncaught (in promise) TypeError: this.page.attachToNewParent is not a function
Examining the source code show it failing in this piece of code
The "this.page.attachToNewParent($(e), this.container_div);" fails in the placeInZone function
placeInZone: function(e, t) {
void 0 === t && (t = 0);
if (!this.isInZone(e)) {
this.items.push({
id: e,
weight: t
});
this.page.attachToNewParent($(e), this.container_div);
this.items.sort(function(e, t) {
return e.weight > t.weight ? 1 : e.weight < t.weight ? -1 : 0
});
this.updateDisplay()
}
},
This code in legacy style works just fine.
Here is my code in the setup function of my game:
// test the zone code in es6 land
// const [zone] = await importDojoLibs(['ebg/zone']);
document.getElementById(`mr_main`).insertAdjacentHTML('beforeend', `
<div id="testZone" style="width:100px; height:100px;border:1px black solid" ></div>
`);
this.testZone = new ebg.zone();
this.testZone.create(this, `testZone`, 100, 100);
this.testZone.setPattern('grid');
this.testZone.placeInZone('mr_disc_5_4_wrapper');
It throws:
Uncaught (in promise) TypeError: this.page.attachToNewParent is not a function
Examining the source code show it failing in this piece of code
The "this.page.attachToNewParent($(e), this.container_div);" fails in the placeInZone function
placeInZone: function(e, t) {
void 0 === t && (t = 0);
if (!this.isInZone(e)) {
this.items.push({
id: e,
weight: t
});
this.page.attachToNewParent($(e), this.container_div);
this.items.sort(function(e, t) {
return e.weight > t.weight ? 1 : e.weight < t.weight ? -1 : 0
});
this.updateDisplay()
}
},