knockout.js

How to import KnockOut 4 in TypeScript?

孤街浪徒 提交于 2020-04-18 05:48:10
问题 This seems simple because the same code works well in simple JS file and it also has autocompletion for the ko variable's members. I have the following TypeScript code below: // both of the following import lines result in: `ko` undefined // import { ko } from "@tko/build.knockout"; import { ko } from "../node_modules/@tko/build.knockout/dist/build.knockout.es6"; alert("test: " + ko); tsconfig.json { "compilerOptions": { "removeComments": true, "preserveConstEnums": true, "sourceMap": true,

How to import KnockOut 4 in TypeScript?

孤街浪徒 提交于 2020-04-18 05:47:12
问题 This seems simple because the same code works well in simple JS file and it also has autocompletion for the ko variable's members. I have the following TypeScript code below: // both of the following import lines result in: `ko` undefined // import { ko } from "@tko/build.knockout"; import { ko } from "../node_modules/@tko/build.knockout/dist/build.knockout.es6"; alert("test: " + ko); tsconfig.json { "compilerOptions": { "removeComments": true, "preserveConstEnums": true, "sourceMap": true,

How do you console log inside a knockout template

我们两清 提交于 2020-03-17 10:11:16
问题 I thought this was correct: <div data-bind="foreach: amount_options, visible: $parent.displayAskAmoutRadioButtons()"> <!-- ko console.log(amount_option) --><!-- /ko --> <label class="donor-js-amount-choice"> <!-- <input type="radio" class="donor-js-webware" name="gift_amt" data-bind="attr: {value: key}, checked: $parent.amountSelected"><span class="donor-js-currency-symbol" data-bind="html: $root.session.currencySymbol"></span> <span class="donor-js-input-currency" data-bind="text: desc"><

How do you console log inside a knockout template

£可爱£侵袭症+ 提交于 2020-03-17 10:09:07
问题 I thought this was correct: <div data-bind="foreach: amount_options, visible: $parent.displayAskAmoutRadioButtons()"> <!-- ko console.log(amount_option) --><!-- /ko --> <label class="donor-js-amount-choice"> <!-- <input type="radio" class="donor-js-webware" name="gift_amt" data-bind="attr: {value: key}, checked: $parent.amountSelected"><span class="donor-js-currency-symbol" data-bind="html: $root.session.currencySymbol"></span> <span class="donor-js-input-currency" data-bind="text: desc"><

Minimal symbols amount for data upload in autocomplete

末鹿安然 提交于 2020-02-29 02:04:53
问题 I'm trying to create city autocomplete in checkout, but the problem is that amount of data that being sent is too large. So i was thinking about uploading data only after certain amount of symbols typed in field, lets say 3. But I don't know how to do this using native bindingHandlers. Here is js file: define([ 'Magento_Ui/js/form/element/abstract', 'mage/url', 'ko', 'jquery', 'jquery/ui' ], function (Abstract, url, ko, $) { 'use strict'; ko.bindingHandlers.shippingAutoComplete = { init:

Knockout/Select2 remove selected options from dropdown options. Without passing down root model

柔情痞子 提交于 2020-02-25 05:40:29
问题 So I have a table with two dropdown lists (per row) that I'm using with knockout and select. I want to be able to disable or remove the selected options that already been selected. Thanks to @Jason Spake I was able to understand the problem from Knockout/Select2 Dropdownlist contains correct options, but now displays nothing as selected. However the solution provided wasn't ideal because I do not want to be passing in the root model to the children models. Would anyone be able to help come up

Adding observable properties to model after ko.applyBindings in knockout.js

佐手、 提交于 2020-02-23 13:04:43
问题 For example function Model(){}; var model = new Model(); ko.applyBinding(model); model.name = ko.observable('john'); I know the code will not work but is it possible to make it work ? 回答1: I was able to accomplish this by using cleanNode and then reapplying the bindings. function Model(){}; var model = new Model(); ko.applyBindings(model); model.name = ko.observable('john'); var myDiv = $('#myDiv')[0]; ko.cleanNode(myDiv); ko.applyBindings(model, myDiv); <div id="myDiv"> <span data-bind="text

Ajax data binding using Knockout Js

∥☆過路亽.° 提交于 2020-02-11 09:52:53
问题 i am using the knockout js , i am finding diffcult to bind the data while in ajax get method, i have created model, viewModel, and ajax function, i have the ajax method in the same js file where i have created viewModel i am calling the ajax on page load and trying to bind my html with konckout js, i am getting the error userModel is undefined if i give this.name = ko.observale(result[0].name) before the ajax call, after the ajax called it give name is undefined need help <html> <head>

Ajax data binding using Knockout Js

杀马特。学长 韩版系。学妹 提交于 2020-02-11 09:50:32
问题 i am using the knockout js , i am finding diffcult to bind the data while in ajax get method, i have created model, viewModel, and ajax function, i have the ajax method in the same js file where i have created viewModel i am calling the ajax on page load and trying to bind my html with konckout js, i am getting the error userModel is undefined if i give this.name = ko.observale(result[0].name) before the ajax call, after the ajax called it give name is undefined need help <html> <head>

using a draggable as a source list links items added to a sortable together?

为君一笑 提交于 2020-02-05 05:01:32
问题 excuse the hacked together sample http://jsfiddle.net/marcmeans/SqrBf/1/ If you add an item from the available students to Table3 twice and then try and move one from Table3 to Table2, both disappear. I note as well that when I'm generating a new guid for the item added to Table3, the arg.item seems be a reference to the item in the source list and not a clone. This creates a link in knockout where if I update one I update them all. I'm assuming that I am doing something wrong here, but I'm