knockout.js

How to carry the data from one viewModel to another ViewModel Knockout JS

半世苍凉 提交于 2020-01-10 05:39:08
问题 I am using the Knockout js in my single page Application,I need to carry the value of one viewmodel data to another viewModel data,So i can reduce my duplication creating same view, How i can achieve this below is my code.I got 2 different js file,which one consist of Employee ViewModel and in another Department View Model //Employee View <div class="Employee-view" data-role="view" id="employee"> <div data-role="content" > <ul> <li foreach:EmployeeData> //Onlcick of this need to navigate to

Unable to parse bindings js error using ko.mapping.fromJSON with parse exist view model

房东的猫 提交于 2020-01-09 23:02:30
问题 I want to save view model in the hidden field in JSON format. All work fine. But when I try to get it - I get error: Uncaught Error: Unable to parse bindings. Message: ReferenceError: selectAll is not defined; Bindings value: checked: AllCheck, click: selectAll JsFiddler viewModel function AppViewModel() { //Week this.AllCheck = ko.observable(false); this.DaysOfWeekResult = ko.observableArray(); this.selectAll = function () { if (this.AllCheck()) { viewModel.DaysOfWeekResult.removeAll();

knockout.js and jQueryUI to create an accordion menu

╄→гoц情女王★ 提交于 2020-01-09 09:51:51
问题 Got a slight problem trying to have jquery UI and knockout js to cohoperate. Basically I want to create an accordion with items being added from knockout through a foreach (or template). The basic code is as follows: <div id="accordion"> <div data-bind="foreach: items"> <h3><a href="#" data-bind="text: text"></a></h3> <div><a class="linkField" href="#" data-bind="text: link"></a></div> </div> </div> Nothing impressive here... The problem is that if I do something like: $('#accordion')

something wrong with performance

风格不统一 提交于 2020-01-07 10:50:44
问题 I am using jquery,knockout and WCF. I am loading data coming from WCF via Ajax request and push data into observable array. This observable array is binded to html table <div style="overflow: hidden;" > <table style="width: 100%" > <thead> <tr> <th>Id </th> <th>Name</th> </tr> </thead> </table> <div style="overflow: auto;height: 320px;"> <table id ="Table1" style="width: 100%;" > <tbody data-bind="foreach: ListOfArray"> <tr data-bind= "click: showData"> <td data-bind="text: Id"></td> <td data

something wrong with performance

不问归期 提交于 2020-01-07 10:49:51
问题 I am using jquery,knockout and WCF. I am loading data coming from WCF via Ajax request and push data into observable array. This observable array is binded to html table <div style="overflow: hidden;" > <table style="width: 100%" > <thead> <tr> <th>Id </th> <th>Name</th> </tr> </thead> </table> <div style="overflow: auto;height: 320px;"> <table id ="Table1" style="width: 100%;" > <tbody data-bind="foreach: ListOfArray"> <tr data-bind= "click: showData"> <td data-bind="text: Id"></td> <td data

Validate javascript inside attributes

自古美人都是妖i 提交于 2020-01-07 09:06:22
问题 I am using Knockout a lot and often times I have to write scripts inside the data-bind attributes. Is there any validation tools that I can use on these markup files to validate the javascript inside data-bind attributes? Would be nice if there is a grunt plugin. 回答1: There probably isn't (a prominent) one, because it's not common to have a lot of complex logic inside your view. With MVVM-like approaches it works best if you keep the View rather plain, and write out logic in your ViewModel

Typescript and Knockout.js

烂漫一生 提交于 2020-01-07 05:30:33
问题 Im trying to get this code working, Im new to typescript and knockout.js I have been doing this piece of code in another way but someone told me this could be a better way to improve the existing code, the problem is, is not working, maybe is a typo but Im not finding it. This is my Typescript: /// <reference path="../typings/index.d.ts" /> $(document).ready(function () { ko.applyBindings(new ABMAlumnosModel()); }); class Alumno { Legajo: KnockoutObservable<string>; Nombre: KnockoutObservable

Knockout checked binding and select all children collection

旧时模样 提交于 2020-01-07 03:45:07
问题 I have a Knockout component which template prints two nested lists of items (checkboxes in my interface): a first foreach loop iterates through some "parents" items, a second (and nested) list iterates through each of the parents items and, if children are found, prints the children. The requirement is that if the user clicks on a parent item (that is, on a parent checkbox), all the children checkboxes become checked. In my code, both parents and children checkboxes listen to an observable

Is there a way to handle 3 level checkboxes with knockout

余生颓废 提交于 2020-01-07 02:25:08
问题 I have the following ko markup which are two nested ol with checkboxes <label><input type="checkbox" data-bind="checkedValue:true, checked: selectAll" />Check all</label> <ol data-bind="foreach: Itemsnum"> <li> <li><label><input type="checkbox" data-bind="checkedValue:true, checked: selectedOptionnum" /> <span data-bind="text: Name"></span></label></li> <ol style="margin-left:10px" data-bind="foreach: $parent.Itemsabc"> <li style="margin-left:10px"><label><input type="checkbox" data-bind=

Knockoutjs track changes after ajax call

孤街醉人 提交于 2020-01-07 01:52:33
问题 See JsFiddle here http://jsfiddle.net/WtgbV/2/ In words: I have some ajax call, and in the server's response I get some array of items (Items in knockout viewmodel) I need to know that property name was changed in element with id==2 etc to save changes automatically on server (via POST request) What is the simplest/easiest way to track changes in each element in Items array? 回答1: I co-wrote a component called DirtyFlag that detects changes in Knockout observables (or a set of them). You can