Hello,
DevExtreme widgets and the new Enhance API are working well together. But of all the scenarios I tested after having implemented my new bridge between Aurelia 2.0 and DevExtreme, and incorporating all of the knowledge I acquired on this forum, I did not test this one (apparently):
bid-jobsites-list.html (NOT WORKING)
<div class="tsi-list-layout">
...
<tsi-dx-popup
visible.two-way="showDescription"
content-template="description"
container=".tsi-list-layout"
>
<dx-template name="description">
<my-description description.bind="someText"></my-description>
</dx-template>
</tsi-dx-popup>
...
</div>
where someText is on the view model associated with bid-jobsites-list.html. After the template is enhanced and ingested into the DevExtreme widget, it loses its context with respect to the view-model associated with the owning view (where it is defined). It cannot find someText.
A number of DevExtreme widgets do not pass in data to some of their templates. In that case, the widget has noModel set to true by the widget internally. Most of the widgets do pass in data, and I hand this off to enhance in the familiar way:
...
onResolve(
Aurelia.enhance({
container: config.container,
host: $template,
component: {
data: renderData.model,
},
}),
(enhancedView) => { ... }
...
All works well. But components like Popup, Popover, Tooltip, etc. have content templates where no data is passed in. Apparently, it is expected that the data will come from the template’s context, not from the widget.
Compared to Aurelia 1.0
This was no problem in Aurelia 1.0. Consider the following from one of my components in Aurelia 1.0:
tsi-model-editor-command-bar.html (WORKING)
...
<tsi-dx-popup visible.bind="confirmClose">
<dx-template name="content">
<div class="tsi-dialog__text">${text.areYouSure}</div>
<div class="tsi-dialog__text">${text.closingWithoutSaving}</div>
<div class="tsi-dialog__buttons-wrapper">
<div class="tsi-dialog__buttons">
<tsi-dx-button styling-mode="text" text.bind="text.keepEditing"
click.delegate="onCancelClose()">
</tsi-dx-button>
<tsi-dx-button type="default" text.bind="text.closeAnyways"
click.delegate="onConfirmClose()">
</tsi-dx-button>
</div>
</div>
</dx-template>
</tsi-dx-popup>
...
If you take a look in the dx-template markup above, you’ll see a reference to text.* in some of the bindings. That’s a field defined on the view-model. You can also see a number of delegate bindings. Their handlers are also on the view-model.
Context was preserved in Aurelia 1.0 and the text bindings and delegate bindings worked even after the enhanced template was ingested.
What’s going on here? Why are the dx-templates not seeing the view-model where they’re defined?