knockout.js

Find the appropriate DOM element

时光毁灭记忆、已成空白 提交于 2020-01-05 04:14:12
问题 Here follows my model: <!-- ko foreach: teamMembers --> <tr> <!-- ko foreach: days --> <td> <!-- ko foreach: shifts --> <input type="text" data-bind="value: startTime"> <input type="text" data-bind="value: endTime"> <!-- /ko --> </td> <!-- /ko --> </tr> <!-- /ko --> and my viewmodel: function TimeCardViewModel() { var self = this; self.teamMembers=ko.observableArray(); } function TeamMemberViewModel(data){ var self=this; self.days=ko.observableArray(); for (var i=0; i<7; i++) { self.days.push

Polling implementation using setInterval in knockout application?

我是研究僧i 提交于 2020-01-05 04:14:12
问题 I am trying to implement simple polling mechanism using setInterval. I have a Viewmodel as follows: define([ 'knockout', 'jquery', ], function ( ko, $) { function ViewModel() { var self = this; //setInterval( function() { $.ajax({url: "", async: false,timeout: 3000, success: function (data) { // some operation }, dataType: "json"}); //}, 3000); } return ViewModel; }); Upto this it works fine ajax call return data and does operation.How do I use setInterval so that ajax call returns data after

Format knockout observable with commas and/or decimal places within html data binding, NOT in viewmodel

余生长醉 提交于 2020-01-05 04:02:18
问题 I've seen RP Niemeyer's answer here: Formatting rules for numbers in KnockoutJS but it doesn't seem to fit my situation. My viewmodel is tightly bound with breeze entities for a start, so I cannot easily mess with the individual table fields. There are c. 40 fields that contain numerical impact calculation results, often to 9 or 10 decimal places. It is essential that the raw result is left untouched in the viewmodel. RP Niemeyer's "extend" based solution seems to suit more a situation where

Add css runtime to table row and data bind the row

安稳与你 提交于 2020-01-05 03:43:06
问题 I am really not sure how to solve. However i am quite close the solution and now just need one small help from you experts here. My working fiddle is here. When the page loads the 2 checkboxes are checked. My view is binded as below <tbody data-bind="foreach: dataOne"> <tr data-bind="css: { 'makeBold': $root.duplicates.indexOf(name1) !== -1 }" > <td data-bind="text: id"></td><td >   </td> <td data-bind="text: display"></td><td >   </td> <td> </td> <td> <input type="checkbox" data-bind=

knockout mapping causing stackoverflow

馋奶兔 提交于 2020-01-05 02:44:13
问题 I'm experimenting with knockout and the mapping plugin and wondering why this doesn't work. I have a viewmodel that I want to load using the mapping extension function todoListViewModel(data) { ko.mapping.fromJSON(data, { todos: TodoItem.options }, self); ko.mapping.fromJSON(data, { todos: TodoItem.options }, self); } the mapping has an options that looks like this: var TodoItem = function (options) { var todoItem = ko.mapping.fromJS(options.data); todoItem.remove = function () { alert(

Knockout.js and large dataset makes dropdown list slow also

与世无争的帅哥 提交于 2020-01-05 02:05:10
问题 Does anyone know why the performance on this page is slow when it comes to the dropdown list on the - ALL - option? I must be doing something wrong with knockout.js for this to happen. For the smaller list of games it opens up quickly. Tournament Schedule Javascript (function (app, $, undefined) { app.viewModel = app.viewModel || {}; function Schedule() { var self = this; self.loaded = ko.observable(false); self.divisionId = ko.observable(); self.games = ko.observableArray(null); self.search

KnockoutJS - Basic Model Architecture

醉酒当歌 提交于 2020-01-04 20:33:43
问题 I've got a web project, where I need to model some basic JavaScript classes and put them into a separate javascript file. Now I want to use them locally on a page and add them into a master view model, which acts as binding object. My question is, how do you realize the connections between model class and master view model? This is the class model from the api: Namespace.Problem = function() { var self = this; self.identifier = ko.observable(); self.summary = ko.observable(); self.title = ko

KnockoutJS - Basic Model Architecture

ぃ、小莉子 提交于 2020-01-04 20:29:44
问题 I've got a web project, where I need to model some basic JavaScript classes and put them into a separate javascript file. Now I want to use them locally on a page and add them into a master view model, which acts as binding object. My question is, how do you realize the connections between model class and master view model? This is the class model from the api: Namespace.Problem = function() { var self = this; self.identifier = ko.observable(); self.summary = ko.observable(); self.title = ko

KnockoutJS - Basic Model Architecture

佐手、 提交于 2020-01-04 20:28:13
问题 I've got a web project, where I need to model some basic JavaScript classes and put them into a separate javascript file. Now I want to use them locally on a page and add them into a master view model, which acts as binding object. My question is, how do you realize the connections between model class and master view model? This is the class model from the api: Namespace.Problem = function() { var self = this; self.identifier = ko.observable(); self.summary = ko.observable(); self.title = ko

Jquery Knockout: ko.computed() vs classic function?

折月煮酒 提交于 2020-01-04 15:28:36
问题 I have a view model function ViewModel() { this.applications = ko.observable(10); this.applicationsText_computed = ko.computed(function () { return "You have " + this.applications() + " applications"; }); this.applicationsText_classinc = function () { return "You have " + this.applications() + " applications"; }; }; var viewModel = new ViewModel(); ko.applyBindings(viewModel); <p data-bind="text: applicationsText_computed()"></p> <p data-bind="text: applicationsText_classic()"></p> Both