knockout.js

Applying knockout extenders after mapping

流过昼夜 提交于 2019-12-23 08:04:19
问题 I'm having a problem with adding a knockout extender to observables after they have been created. In the following example the extender is run on foo every time the value changes as expected but only once, when first called, for bar . var viewModel = function(){ var self = this; self.foo = ko.observable(1).extend({ numeric: 1 }); self.bar = ko.observable(1); self.bar.extend({ numeric: 1 }); }; Essentially I am mapping a large JSON object and would like to add extenders after the mapping has

Applying knockout extenders after mapping

一笑奈何 提交于 2019-12-23 08:03:28
问题 I'm having a problem with adding a knockout extender to observables after they have been created. In the following example the extender is run on foo every time the value changes as expected but only once, when first called, for bar . var viewModel = function(){ var self = this; self.foo = ko.observable(1).extend({ numeric: 1 }); self.bar = ko.observable(1); self.bar.extend({ numeric: 1 }); }; Essentially I am mapping a large JSON object and would like to add extenders after the mapping has

Knockout and MVC 2.0

▼魔方 西西 提交于 2019-12-23 07:54:50
问题 Does anyone know of an example application using knockout js and MVC 2? I'm trying to learn knockout and am having trouble grasping how to persist model data via an ajax call to an action. 回答1: There's a great post here by the author of Knockout on how to use it with MVC. In MVC 2 you can use the built in model binder instead of a [FromJson] attribute like the article suggests. Congrats on finding Knockout. My team has absolutely loved working with it. One of our guys replaced a dynamic

Knockout and MVC 2.0

为君一笑 提交于 2019-12-23 07:52:19
问题 Does anyone know of an example application using knockout js and MVC 2? I'm trying to learn knockout and am having trouble grasping how to persist model data via an ajax call to an action. 回答1: There's a great post here by the author of Knockout on how to use it with MVC. In MVC 2 you can use the built in model binder instead of a [FromJson] attribute like the article suggests. Congrats on finding Knockout. My team has absolutely loved working with it. One of our guys replaced a dynamic

Does the simpleGrid require additional downloads?

。_饼干妹妹 提交于 2019-12-23 07:48:13
问题 I want to try the simpleGrid in a HotTowel project. When it came to: this.gridViewModel = new ko.simpleGrid.viewModel({ data: this.items, .... it threw an exception: Unable to get property 'viewModel' of undefined or null reference` I stepped through and found that ko.simpleGrid is undefined. Must any other files be added or is simpleGrid available from the standard Knockout.js library? 回答1: Check the fiddle (http://jsfiddle.net/rniemeyer/QSRBR/) provides in the Simple Grid sample. It need

KnockOut run function on value changed

泄露秘密 提交于 2019-12-23 07:39:04
问题 Got simple viewModel: function viewModel() { enabled: ko.observable(false); ... } and some binding like: <input data-bind="hasFocus: enabled" /> and i want run some function on focus, and other on focus lost( or enabled = true/false) but run when value changes. Any help? 回答1: You could subscribe to your enabled function, such as: enabled.subscribe(function(newValue) { if(newValue) { // Has focus } else { // No focus } }); 回答2: event: { mouseover: enableDetails, mouseout: disableDetails } Try

Knockout 'for' binding?

最后都变了- 提交于 2019-12-23 07:22:08
问题 Original Question Does any one have or know of a binding for knockout that would allow behavior similar to a for loop? I can make a foreach do what I want but it would be nice if I didn't have to do it that way. Edit 2 I am trying to create table rows based on a selection the user makes. In some cases I need x rows where x is the length of an array, other times x represents the largest number rows that will be needed to display n number of arrays. Ex: image1 is built based on 4 different

knockoutjs with mvc collection model binding

淺唱寂寞╮ 提交于 2019-12-23 05:39:25
问题 I'm using knockoutjs to render a collection of items. After allowing the user to do some inline editing I need to post the collection back to the server. However, the collection isn't being populated on the server because I'm not using the name="[0].Blah" naming convention. Does anyone know how to either render name attributes like this using knockoutjs OR how to create a model binder that will allow me to extract the values from the ValueProvider? You can see a screenshot of the

Passing the model as argument in the link button click using KO

自古美人都是妖i 提交于 2019-12-23 05:33:11
问题 In this below example I need to pass the model as argument in the link button click (List, range) . how to acheive this <div data-bind = "foreach:modelList" > <div class="BDCRQuery"> <div class= "Body" > <div> <select id ="SELECT" data-bind="options: Attributes, optionsText: 'AttributeName', optionsValue: 'Id', optionsCaption: 'Select Attribute...',value : SelectedAttribute"></select> </div> <div> <span>with any of the following values:</span> </div> <div class="option"> <a href="#" id =

bind different Knockout JS templates inside foreach loop

六月ゝ 毕业季﹏ 提交于 2019-12-23 05:20:12
问题 I am trying to use KO templates to parse a JSON file (see here) into some pretty looking grid layouts.. (think similar to masonry/isotope layouts).. each template section will have different sized rectangles and squares inside it but the overall template conforms to a grid of 5 boxes wide by 3 boxes high (for example) Given this what i have been trying to do is detect the template, then iterate through each item, if its a certain index in the iteration load either the single, double, or