使用淘汰赛js弹出

Popup using knockout js(使用淘汰赛js弹出)
本文介绍了使用淘汰赛js弹出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将我的一个旧 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弹出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Update another component when Formik form changes(当Formik表单更改时更新另一个组件)
Formik validation isSubmitting / isValidating not getting set to true(Formik验证正在提交/isValiating未设置为True)
React Validation Max Range Using Formik(使用Formik的Reaction验证最大范围)
Validation using Yup to check string or number length(使用YUP检查字符串或数字长度的验证)
Updating initialValues prop on Formik Form does not update input value(更新Formik表单上的初始值属性不会更新输入值)
password validation with yup and formik(使用YUP和Formick进行密码验证)