knockout.js - Durandal 2.0 custom dialog -


I want to create a fearindle custom dialog which is an existing compose-worthy view-model with a title and footer Adds window frames.

I have a custommodel template

  and div 

As you can see, I want to prepare a view-model within the custommodal template body. This is because Vyöllold has not been passed, which is linked to a model display, but can easily use it.

I have created a custom model .js model like this:

  define (['plugins / dialog'], function (dialog) {var custommodel = function ( Title, model, view, option) {this.title = title; this.model = model; this.view = view; this.options = option;}; CustomModel.prototype.SetOption = function (dialog) {dialog.close ( This, dialogue result);}; return custommodel;});   

But when I try and use it to bind the '.html' template,

Am I missing something here? And is it really the best way to do this?

Thank you.

I created a simple example in which you can use as the starting point. It contains an index view / VM that opens an existing view / VM in a custom modal. The current visual model is shut down so that it can be accessed.

index.js
  define (function (required) {"strict use"; var app = required ('dundall / app'), custom digital = Required ('./ customModal'), existing = requires ('./ presentView'), ctor; ctor = function () {this.dialog;}; ctor.prototype.showCustomModal = function () { This.dialog = new custom dialog ('my title', new current ()); this.dialog.show (). Then (function (feedback) {app.showMessage ('model title' '+ response.title +' ' . '';});}; Return ctor;});   

index
  
gt; & lt; h3 & gt; ; Durandle 2.0 Custom Dialog & l T; / h3 & gt; & lt; a href = "#" data-bind = "click: $ data.showCustomModal" & gt; click here & lt; / a & gt; To open, define

customModal.js
  (['plugins / dialog'], function ( Dialog) {var custommodel = function (title, model) {this .title = title; this.model = model;}; Custom modal.prototype.oc = function () {dialog.close (this, this.model);}; Custom modal.prototype.Show = function () {return dialog. Show (this);} return custommodel;});   

customModal.html
  & lt; Div class = "message box" & gt; & Lt; Div class = "modal-header" & gt; & Lt; H3 Data-Bind = "Text: Title" & gt; & Lt; / H3 & gt; & Lt; / Div & gt; & Lt; Div class = "modal-body" & gt; & Lt ;! - Write to: $ data.model - & gt; & Lt; -! / Ko - & gt; & Lt; / Div & gt; & Lt; Div class = "modal-footer" & gt; & Lt; Button class = "btn btn-primary" data-bind = "click: okay" & gt; OK & lt; / Button & gt; & Lt; / Div & gt; & Lt; / Div & gt; Define   

existing View.js
  (function () {var ctor = function () {this.title = 'I';}; Return Ctor;});   

Existing view html
  & lt; P data-bound = "text: title" & gt; & Lt; / P & gt;   

Live version available here. Feel free to fork.

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -