'Creating dialog using OJET
I am trying to create OJET dialog. Though I am directly using code from cookbook I am getting error like "Uncaught (in promise) Error: You cannot apply bindings multiple times to the same element.".
Below is the code I am using .
<div id="dialogWrapper">
<oj-dialog id="modalDialog1" dialog-title="Modal Dialog">
<div slot="body">
This is the dialog content.
User can change dialog resize behavior, cancel behavior and drag behavior by setting attributes.
Default attribute value depends on the theme.
</div>
<div slot="footer">
<oj-button id="okButton" on-oj-action="[[close]]">OK
</oj-button>
</div>
</oj-dialog>
<oj-button id="buttonOpener" on-oj-action="[[open]]">
Open Modal Dialog
</oj-button>
<div class="oj-sm-padding-4x-top" id='form-container'>
<oj-form-layout direction="row" max-columns="1">
<oj-input-text value="{{textVal1}}" label-hint="Address 1"></oj-input-text>
<oj-input-text value="{{textVal2}}" label-hint="Address 2"></oj-input-text>
</oj-form-layout>
</div>
</div>
Corresponding ViewModel code is
require(["require", "exports", "knockout", "ojs/ojbootstrap", "ojs/ojknockout", "ojs/ojbutton", "ojs/ojdialog", "ojs/ojformlayout", "ojs/ojinputtext"], function (require, exports, ko, Bootstrap) {
"use strict";
class viewModel {
constructor() {
this.textVal1 = ko.observable("");
this.textVal2 = ko.observable("");
}
close(event) {
document.getElementById("modalDialog1").close();
}
open(event) {
document.getElementById("modalDialog1").open();
}
}
Bootstrap.whenDocumentReady().then(() => {
ko.applyBindings(new viewModel(), document.getElementById("dialogWrapper"));
});
});
Can someone please help me to understand what is the mistake I am doing?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|