我正在将我的一个旧 jquery 插件从 DOM 丛林迁移到这个花哨的 mvvm 框架淘汰赛.
i'm migrating one of my older jquery plugins from DOM jungle to this fancy mvvm framework knockout.
我将使用哪种技术来正确显示弹出容器?我必须通过调用"填充它,因为我每次都会得到一个 json 提要.
Which technique would i use to properly display a popup container? I ahve to populate it 'by call' since i get a json feed every time.
我尝试了一种使用 with 绑定的方法,但它仍然尝试在第一次运行时填充部分.
I tried an approach using the with binding, but it still attempts to populate the partial at its first runtime.
<!-- ko with: daySubmitFormViewModel -->
<div class="ec-consulation-lightbox">
<form id="cForm" class="form-container">
// Some bindings here.
</form>
</div>
<!-- /ko with: -->
也可以不用自定义绑定.示例如下
It can be done without custom binding as well. Example is below
<div class="modalWindowBackground" data-bind="visible: popupDialog" >
<div class="modalWindow" data-bind="with:popupDialog">
<div class="content">
<h2 data-bind="text: title"></h2>
<p>
<span data-bind="text: message"></span>
</p>
<div class="buttonSpace">
<input type="button" class="closeButton" data-bind="value: closeButtonText, click: $root.hidePopupDialog" />
</div>
</div>
</div>
</div>
视图模型代码:
self.showAlert = function (title, message, closeButtonText) {
self.popupDialog({ title: title, message: message, closeButtonText: closeButtonText });
};
self.hidePopupDialog = function () {
self.popupDialog(null);
};
//Code which opens a popup
self.remove = function () {
.... some code ...
if (someCondition) {
self.showAlert('SomeTitle', 'Message', 'OK');
return;
}
.... some code ...
};
这篇关于使用淘汰赛js弹出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!