html Durandal.JS运行模态的示例。

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了html Durandal.JS运行模态的示例。相关的知识,希望对你有一定的参考价值。

/// <reference path="../../dataservices/account.js" />
/// <reference path="../../../Scripts/jquery-2.0.3.js" />
/// <reference path="../../../Scripts/require.js" />
/// <reference path="../../../Scripts/knockout-2.3.0.debug.js" />

define([
    "jquery",
    "durandal/app",
    "./create"],
    function ($, app, createForm) {

        return {
            grid: undefined,
            activate: function(){
                var _Self = this;
            },
            compositionComplete: function () {
            },
            deactivate: function () {
            },
            create: function () {
                createForm.show();
            },
            edit: function (id) {
                var dataService = provider.define("DatabaseServer");

                dataService.get({ id: id })
                .then(function (data) {
                    // if you want to pass data in, your "show()" method should
                    // have the parameter(s) available to accept the data you want
                    // to pass.
                    editForm.show(data);
                });
            }
        }
    });
/// <reference path="../../../Scripts/jquery-2.0.3.js" />
/// <reference path="../../../Scripts/require.js" />
/// <reference path="../../../Scripts/knockout-2.3.0.debug.js" />
/// <reference path="../../../Scripts/durandal/plugins/router.js" />

define([
    "plugins/dialog",
    "plugins/observable",
    "durandal/app"],
    function (dialog, observable, app) {

        // supposed to return a function here, not an object?!

        var ctor = function () { };

        ctor.prototype.title = "Modal's Title";

        ctor.prototype.cancel = function () {
            dialog.close(this);
        }

        ctor.prototype.save = function () {
            var _Self = this;
            
            // do some silly work
            // you'll most likely be in a deffered function, which is why you need to capture
            // "this" into "_Self" so that you can call with the right "this" object.
            dialog.close(_Self);
        };

        ctor.show = function ("your object to pass goes here.}) {
            var dlg = new ctor();

            dlg.model = { your object you passed };

            // any work you need to do, validation, whatever...

            return dialog.show(dlg);
        };

        return ctor;
    });
<div class="messageBox wideMessageBox">
    <div class="modal-header">
        <h3 data-bind="text: title"></h3>
    </div>
    <div class="modal-body">
      <!-- Whatever you want here to display in your modal -->
    </div>
    <div class="modal-footer">
        <!-- only because i have save/cancel bindings on my module above. -->
        <button class="btn btn-default" data-bind="click: cancel">Cancel</button>
        <button class="btn btn-primary" data-bind="click: save">Save</button>
    </div>
</div>

以上是关于html Durandal.JS运行模态的示例。的主要内容,如果未能解决你的问题,请参考以下文章

Durandal:在一个孩子中创建功能并从另一个孩子中消费

Durandal js,所有功能在启动时激活

Select2 Js 下拉菜单在 durandal Js 中不起作用

Durandal JS 淘汰赛延期更新

分享20个华丽的模态窗口弹出效果示例

html 完整示例 - 在模态中自动播放youtube视频(Bootstrap + Jquery)