我有以下JS代码
self.tagBuild = {
systemId : ko.observable(),
releaseVersion : ko.observable(),
subReleaseVersion : ko.observable(),
templateSize : ko.observable(),
rehydrationCode : ko.observable(),
repoLocation : ko.observable(),
templateLocation : ko.observable(),
faIntegLabel : ko.observable(),
rehydrationCode : ko.observable(),
cdrmDBTemplate : ko.observable(),
dbOperation :ko.observable()
}
我正在使用下面的代码初始化值
self.tagBuild.systemId(self.jobDetails().system_id);
self.tagBuild.releaseVersion(self.jobDetails().faReleaseVersion);
self.tagBuild.templateSize(self.jobDetails().templateSize);
self.tagBuild.rehydrationCode(self.jobDetails().repoLocation + "/ovm-tooling/oracle-ovmautomation-all.zip");
self.tagBuild.repoLocation(self.jobDetails().repoLocation);
self.tagBuild.templateLocation(self.jobDetails().templateLocation);
我使用tagBuild打开一个对话框。问题是当用户更改UI中的值时,self.tagBuild.templateSize()或其他可观察对象中的值不会更改。可能是什么问题?
html代码在下面使用了observable
<div slot="body">
<!-- ko with:tagBuild-->
<div class="oj-form-layout">
<div class="oj-form oj-sm-odd-cols-12 oj-md-odd-cols-4 oj-md-labels-inline oj-form-cols-labels-inline oj-form-cols-max2">
<div class="oj-flex">
<div class="oj-flex-item">
<oj-label for="systemID" >System ID</oj-label>
</div>
<div class="oj-flex-item">
<oj-input-text id="releaseVersion" data-bind="attr: {value:systemId,readonly:true} " ></oj-input-text>
</div>
</div>
<div class="oj-flex">
<div class="oj-flex-item">
<oj-label for="releaseVersion" >Release Version</oj-label>
</div>
<div class="oj-flex-item">
<oj-input-text id="releaseVersion" data-bind="attr: {value:releaseVersion}" ></oj-input-text>
</div>
</div>
<div class="oj-flex">
<div class="oj-flex-item">
<oj-label for="subReleaseVersion">Sub Release Version</oj-label>
</div>
<div class="oj-flex-item">
<oj-input-text id="subReleaseVersion" data-bind="attr: {value:subReleaseVersion}"></oj-input-text>
</div>
</div>
<div class="oj-flex">
<div class="oj-flex-item">
<oj-label for="templateSize">Template Size</oj-label>
</div>
<div class="oj-flex-item">
<oj-input-text id="templateSize" data-bind="attr: {value:templateSize}"></oj-input-text>
</div>
</div>
<div class="oj-flex">
<div class="oj-flex-item">
<oj-label for="templateSize1">Template Size</oj-label>
</div>
<div class="oj-flex-item">
<oj-input-text id="templateSize1" data-bind="attr: {value:templateSize}"></oj-input-text>
</div>
</div>
<div class="oj-flex">
<div class="oj-flex-item">
<oj-label for="repoLocation">Repo Location</oj-label>
</div>
<div class="oj-flex-item">
<oj-input-text id="repoLocation" data-bind="attr: {value:repoLocation}"></oj-input-text>
</div>
</div>
<div class="oj-flex">
<div class="oj-flex-item">
<oj-label for="templateLocation">Template Location</oj-label>
</div>
<div class="oj-flex-item">
<oj-input-text id="Config" data-bind="attr: {value:templateLocation}"></oj-input-text>
</div>
</div>
<div class="oj-flex">
<div class="oj-flex-item">
<oj-label for="FAIntegLabel">FA Integ Label</oj-label>
</div>
<div class="oj-flex-item">
<oj-input-text id="FAIntegLabel" data-bind="attr: {value:faIntegLabel}"></oj-input-text>
</div>
</div>
<div class="oj-flex">
<div class="oj-flex-item">
<oj-label for="rehydrationCode">Rehydration Code </oj-label>
</div>
<div class="oj-flex-item">
<oj-input-text id="rehydrationCode" data-bind="attr: {value:rehydrationCode}"></oj-input-text>
</div>
</div>
<div class="oj-flex">
<div class="oj-flex-item">
<oj-label for="cdrmDBTemplate">CDRM DB Template </oj-label>
</div>
<div class="oj-flex-item">
<oj-input-text id="cdrmDBTemplate" data-bind="attr: {value:cdrmDBTemplate}"></oj-input-text>
</div>
</div>
</div>
</div>
<!--/ko-->
</div>
<div slot="footer">
<oj-button id="okButton" class='oj-button-primary' data-bind="click: saveBuildTags">Submit</oj-button>
</div>
</oj-dialog>
这类似于我帮助你的previous problem。您必须更正定义Oracle-JET组件的方式。
data-bind
用于Oracle-JET组件,它们已在内部使用。你必须直接使用oj-input-text
的属性。重做你所有的oj-input-text
标签,如下所示:
<oj-input-text id="releaseVersion" value="{{systemId}}" readonly></oj-input-text>
请注意,readonly
也是oj-input-text
标签的属性,因此它可以很好地工作,提供OJET样式以将输入转换为只读模式。
这里是Cookbook,它向您展示了标签的正确语法,这里是documentation,它显示了您可以用于标签的每个属性。
附:请把Cookbook当作OJET的圣经。它写得很漂亮,非常彻底。您将无法以任何其他方式使用OJET组件。