durandal-2.0

Durandal constructor function but still want to remember data

谁说我不能喝 提交于 2019-12-06 08:55:47
Let's say I have the following durandal code: define(['durandal/app', 'plugins/http'], function (app) { var vm = function(){ var self = this; self.myData = ko.observableArray([]); } }; vm.activate = function() { this.myData([]); }; vm.deactivate = function(){ }; return vm; }; I know by returning a constructor function, every time the view model is activated, it will return a new instance. My question is: is there anyway that when I access, if there's myData() from previous access, then I don't want to set this.myData([]); but to use the previous myData() ? I know by returning a singleton

Durandal router / lifecycle events when using a childRouter

↘锁芯ラ 提交于 2019-12-04 07:30:47
In a single page app built using Durandal, I have a settings view, with different sections. I use a childRouter to resolve the different sections. In this application, a lot of code hooks into the composition lifecycle events that Durandal uses. For example, this custom binding: ko.bindingHandlers.autoFocus = { init: function (element) { var $element = $(element), setFocus = function () { $element.focus(); }; router.on('router:navigation:composition-complete', setFocus); ko.utils.domNodeDisposal.addDisposeCallback(element, function () { router.off('router:navigation:composition-complete',

Durandal 2.0 custom dialog

耗尽温柔 提交于 2019-11-30 21:50:26
I wish to make a Durandal custom dialog that adds a window frame with title and footer around an existing composable viewmodel. I have made a customModal.html template <div class="messageBox"> <div class="modal-header"> <h3 data-bind="text: title"></h3> </div> <div class="modal-body"> <!--ko compose: { model: model, template: view }--> <!--/ko--> </div> <div class="modal-footer" data-bind="foreach: options"> <button class="btn" data-bind="click: function () { $parent.selectOption($data); }, text: $data, css: { 'btn-primary': $index() == 0, autofocus: $index() == 0 }"></button> </div> </div> As

Durandal: Showing a 'LOADING…' during composition

我只是一个虾纸丫 提交于 2019-11-30 13:21:29
问题 I can easily show a loading message while the activate method is doing its thing like so: <div data-bind="compose:ActiveVm"> <div class="text-center" style="margin : 75px"> <i class="fa fa-spinner fa-spin"></i> </div> </div> However if I then update my ActiveVm property with a different viewmodel, the splash content does not show. I understand that the splash content is only designed to show on 'initial' load, but what options do I have for displaying such a message when transitioning from

Durandal: Showing a 'LOADING…' during composition

寵の児 提交于 2019-11-30 07:07:05
I can easily show a loading message while the activate method is doing its thing like so: <div data-bind="compose:ActiveVm"> <div class="text-center" style="margin : 75px"> <i class="fa fa-spinner fa-spin"></i> </div> </div> However if I then update my ActiveVm property with a different viewmodel, the splash content does not show. I understand that the splash content is only designed to show on 'initial' load, but what options do I have for displaying such a message when transitioning from one viewmodel to another? Note that this composition does not participate in routing... Update: Related

Auto-generate Div Ids for Bootstrap Accordion Menu binding with Knockout js

不打扰是莪最后的温柔 提交于 2019-11-28 12:24:01
问题 I am creating a side menu using bootstrap accordion collapse and making use of knockout js binding. My problem is in assigning the right HTML element ids for toggle and collapse purposes as required by bootstrap. I have though of using the $indexin knockout to autogenerate the id. But not coming right. See my code below and comments: <div id="content" style="font-size: 8.8pt"> <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true"> <div class="panel panel-default"