knockout.js

Why are template divs showing as “:hidden” in afterRender?

无人久伴 提交于 2019-12-25 02:11:58
问题 Why are template divs showing as ":hidden" in afterRender? Here's the code: <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script> <script src="js/jquery.tmpl.js"></script> <script src="js/knockout-1.2.1.debug.js"></script> <script> $(document).ready(function() { m = function (name) { this.name = name; } viewModel = { a : ko.observableArray(), sparkie : function (elements) { div = elements[0]; console.log($(div).is(':hidden')); }, } ko

Knockout.js Setting SelectedOption to an object

ぃ、小莉子 提交于 2019-12-25 02:04:17
问题 I'm on my first Knockout project and working trying to figure out the best way to handle this situation. Hopefully this dumbed down example serves it's purpose. I am trying to edit a 'project' object which has a property for 'employee'. function Project(data) { var self = this; self.Name = data.Name; self.Employee = data.Employee; } function Employee(data) { var self = this; self.ID = data.ID; self.Name = data.Name; } I first load up my project and then set the 'selectedEmployee'. var me =

knockout - issue with accessing a nested property

橙三吉。 提交于 2019-12-25 01:56:25
问题 I'm trying to learn knockoutjs by studying existing sourcecodes and making small changes to them.. The source code that I'm trying to understand here is an example of knockout-sortable.js by RP Niemeyer. The original example code is here I have made some small changes which are here The original code has a global property called maximumstudents which checked the number of students in each table. I have added a property in table called "maxstudents" which will decide how many students can sit

ASP.NET with Knockout variable length list with combobox - how to bind?

廉价感情. 提交于 2019-12-25 01:56:14
问题 With the following ASP.NET models public class User { public string Name { get; set; } public LEmail LEmail { get; set; } } public class LEmail { public IList<CLabel> Labels; public IList<CEmail> Emails; } public class CLabels { public IList<CLabel> Labels { get; set; } } public class CLabel { public string Name { get; set; } } public abstract class CEmail { public string SelectedLabel { get; set; } public string Name { get; set; } } Filling it out with dummy data and sending to appropriate

KnockoutJS Validation binding value passed to custom binding?

淺唱寂寞╮ 提交于 2019-12-25 01:54:02
问题 Using KnockoutJS-Validation, I need to pass to a custom binding whether the field passed validation or not. Guessing I need to somehow hook into a KnockoutJS-Validation observable at field level using the allBindingsAccessor parameter but unsure how. ko.bindingHandlers.mycustombinding = { update: function (element, valueAccessor, allBindingsAccessor) { allBindings = allBindingsAccessor(), validationObservable = allBindings.validationObservable; if (!validationObservable) { //do cool jQuery

iam unable to applybindings in knockout is this correct approach?

旧时模样 提交于 2019-12-25 01:49:45
问题 i have two view models and i want applybindings one view modek is Div specific and the other one is full page var profileModel = { first: ko.observable("Bob"), last: ko.observable("Smith") }; var shellModel = { header: ko.observable("Administration"), sections: ["profile", "settings", "notifications"], selectedSection: ko.observable() }; ko.applyBindings(shellModel); ko.applyBindings(profileModel, document.getElementById("profile")); 回答1: Hi @Jairam you can make a object with two view model

Multiple nested JQuery UI Accordion generated through Knockout template does not bind correctly

爷,独闯天下 提交于 2019-12-25 01:46:13
问题 I'm trying to get a multiple-nested accordion control to work with Knockout but when adding panels the items created through KO bindings do not bind with the accordion as new panels. The code looks like this: <div data-bind="accordion: {collapsible: true, active: false, heightStyle: 'content'}, template: { name: 'queryTemplate', foreach: children }"> </div> <script id="queryTemplate" type="text/html"> <h3> <div> <a href="#" data-bind="text: id"></a>  <span data-bind="text: name"></span> 

how to iterate through knockout viewmodel collection

戏子无情 提交于 2019-12-25 01:46:03
问题 Iam not able to display product items with Knockout.js library. Html <p>First product: <strong data-bind="text: products[0].description"></strong></p> <tbody data-bind="foreach: products"> <tr> <td data-bind="text: id"></td> <td data-bind="text: description"></td> </tr> </tbody> JavaScript <script type='text/javascript'> $(function () { var json = { "products": [ { "id": 1, "description": "product A" }, { "id": 2, "description": "product B" }, { "id": 3, "description": "product C" } ] }

ReCaptcha: “The bind parameter must be an element or id”

做~自己de王妃 提交于 2019-12-25 01:44:45
问题 ReCaptcha has stopped working on our knockout site. I get the following error in the console: Uncaught Error: The bind parameter must be an element or id at kr (recaptcha__en.js:369) at nr (recaptcha__en.js:373) at Object.or [as render] (recaptcha__en.js:374) at loadReCaptcha (KnockoutBindings.js:135) at KnockoutBindings.js:143 I have a custom binding to handle the ReCaptcha. <div id="reCaptcha" data-bind="reCaptcha: {key: 'my-key', callback: reCaptchaResponse}"></div> Handled by: ko

KnockoutJS duplicating data overhead

放肆的年华 提交于 2019-12-25 01:24:19
问题 For the past few days I'm getting more interested in Knockoutjs. It looks very promising because it models the MVVM pattern and WPF like bindings, but I do have some doubts whenever it bring something useful to non RIA web apps (and when I say RIA I mean complex in browser applications, let's say an ERP, anyway something a bit more complex than adding a few rows to a table and hiding one) Let's say you have a combobox with 10 items, and you need to be able to create on client side another 2