knockout.js

Retrieve boolean value from selected array object

ⅰ亾dé卋堺 提交于 2020-02-05 00:00:57
问题 Objective I'm trying to create a form that will display different dropdown(select) lists based on a single first choice of "Plan Type" e.g.("Basic", "Standard", "Deluxe"). If a user selects "Basic", then the user can choose from a new dropdown list called "Option A". If they select "Standard" or "Deluxe" then they receive "Option B". Edit to Objective I guess I just really need to have the isOptionA or isOptionB available for consumption in my view. Requirement The user can only see the

Retrieve boolean value from selected array object

倖福魔咒の 提交于 2020-02-04 23:59:06
问题 Objective I'm trying to create a form that will display different dropdown(select) lists based on a single first choice of "Plan Type" e.g.("Basic", "Standard", "Deluxe"). If a user selects "Basic", then the user can choose from a new dropdown list called "Option A". If they select "Standard" or "Deluxe" then they receive "Option B". Edit to Objective I guess I just really need to have the isOptionA or isOptionB available for consumption in my view. Requirement The user can only see the

Retrieve boolean value from selected array object

旧巷老猫 提交于 2020-02-04 23:58:57
问题 Objective I'm trying to create a form that will display different dropdown(select) lists based on a single first choice of "Plan Type" e.g.("Basic", "Standard", "Deluxe"). If a user selects "Basic", then the user can choose from a new dropdown list called "Option A". If they select "Standard" or "Deluxe" then they receive "Option B". Edit to Objective I guess I just really need to have the isOptionA or isOptionB available for consumption in my view. Requirement The user can only see the

ko.computed property to determine visibility not working

我只是一个虾纸丫 提交于 2020-01-30 08:17:06
问题 In my KncokoutJS ViewModel, I have the follow computed property: self.SelectedUserHasRoles = ko.computed(function () { if (self.isLoaded()) { return self.selectedUser().roles().length > 0; } return false; }); And in my HTML, I have the following: <!-- ko if: isLoaded() --> <!-- ko if: !SelectedUserHasRoles --> <div> <p>User has no Roles.</p> </div> <!-- /ko --> <!-- ko if: SelectedUserHasRoles --> <div class="roles-wrapper" data-bind="foreach: $root.selectedUser().roles()"> <div class="role

Adding decimal formatting to Knockout number data bindings

大兔子大兔子 提交于 2020-01-29 04:35:07
问题 I am using knockout to populate number values inside a table: HTML: <tbody data-bind="foreach: commision"> <tr> <td> <span>R </span><span data-bind="text: Amount"></span> </td> </tr>... </tbody> Knockout.js part pertaining to amount and commision var vm = { commision: ko.observable(), futurecommision: ko.observable(), commisionpaid: ko.observable(), totals: ko.observable(), commisionPaid: ko.observable(ko.utils.unwrapObservable(ko.mapping.fromJS({ Date: null, Amount: 0 }))), ... Now how do i

DukeScript: how to access the Java model from the JavaScript context?

怎甘沉沦 提交于 2020-01-25 17:28:49
问题 This is related to 1 and 2. I've read the excellent documentation "Using the Knockout API". That explains how the context is set of a specific widget with knockout bindings. Now I'd like to be able to access Java models from the Firebug command line, as I would normally do when I access the ViewModel in Javascript using KnockoutJS in a browser. Firebug doesn't know about "$root", basically I don't know how, and whether it'd be possible at all, to access the Java model at all and call

DukeScript: how to access the Java model from the JavaScript context?

倖福魔咒の 提交于 2020-01-25 17:27:22
问题 This is related to 1 and 2. I've read the excellent documentation "Using the Knockout API". That explains how the context is set of a specific widget with knockout bindings. Now I'd like to be able to access Java models from the Firebug command line, as I would normally do when I access the ViewModel in Javascript using KnockoutJS in a browser. Firebug doesn't know about "$root", basically I don't know how, and whether it'd be possible at all, to access the Java model at all and call

Proper dependecy tracking in a custom binding

ⅰ亾dé卋堺 提交于 2020-01-25 08:24:05
问题 What I'm trying to achieve is to visually filter table rows generated by the foreach binding in a way that tr elements of the rows that are filtered out would be hidden instead of removed from the DOM. This approach significantly improves rendering performance when a user changes filter conditions. This is why I don't want the foreach to be bound to a computed observable array which is updated depending on the filter condition. I want this solution to be a ready-to-use building block that I

Update is not called in knockout.js custom binding

*爱你&永不变心* 提交于 2020-01-25 05:33:07
问题 Here is a code snippet <!DOCTYPE html> <html> <body> <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/knockout/3.3.0/knockout-min.js"></script> <div> <div data-bind="yourBindingName: someValue "> </div> <button data-bind="click: clickme">Click me!</button> </div> <script type="text/javascript"> ko.bindingHandlers.yourBindingName = { init: function (element, valueAccessor, allBindings, viewModel, bindingContext) { console.log("init"); }, update: function (element,

Durandal modal/dialog context that allows scrolling on mobile devices

旧街凉风 提交于 2020-01-25 01:09:22
问题 Durandal provides a modal dialog facility which works great on desktop devices, and it allows you to control the presentation of the dialog via the "dialog context". The default dialog context will, among other things, "display your dialog's view centered on the screen." Observationally, I can see that this means centering the dialog in the viewport--which means that as you scroll up and down, it remains in the same location, in the middle of your viewport. This works fine a screen large