knockout-mvc

Knockout MVC with existing C# code - looping

泪湿孤枕 提交于 2019-12-08 11:52:41
问题 The code in my view - @{ int tabIndex = 0; } @using (var metricGroup = ko.Foreach(m => m.MetricGroups)) { tabIndex++; <div id="tabs-@tabIndex" > ... </div> } The issue here is for all the divs rendered, the id is always the same - "tabs-1" instead of that, it should be "tabs-1", "tabs-2", "tabs-3" ... Can anyone please help me out with this issue? I have a highly complex view and Knockout MVC is driving me crazy 回答1: Because of the ko.Foreach your HTML will be generated on the client side ,

How can I bind a ko.observableArray of strings?

倖福魔咒の 提交于 2019-12-05 21:06:36
问题 I'm trying to bind a ko.observableArray of strings to a template, but I'm unable to get the template to pick up changes in the strings inside the array. If I bind a set of objects instead of a set of strings, I get updates to the JSON, but they don't trigger anything until I actually change the first, non-array value. I'd prefer to find an array of strings, however, as I will be able to post the data model directly back to the server without any post-processing. How can I get the updates to

Converting circular structure to JSON in knockout js

淺唱寂寞╮ 提交于 2019-12-04 05:57:06
问题 I have two grid structure, In one of them I have multiple fields multiple times, whereas, in one I have two fields single time. I write apply method for each grid my first grid id working fine, but when I am clicking apply on second grid I am getting this error Uncaught TypeError: Converting circular structure to JSON Here are both the apply methods: self.applyRate = function (loan) { // commit the edit transaction self.editTransaction.notifySubscribers(null, "commit"); alert(ko.toJSON({data

How can I bind a ko.observableArray of strings?

杀马特。学长 韩版系。学妹 提交于 2019-12-04 03:48:23
I'm trying to bind a ko.observableArray of strings to a template, but I'm unable to get the template to pick up changes in the strings inside the array. If I bind a set of objects instead of a set of strings, I get updates to the JSON, but they don't trigger anything until I actually change the first, non-array value. I'd prefer to find an array of strings, however, as I will be able to post the data model directly back to the server without any post-processing. How can I get the updates to my arrays of strings to trigger, and how can I ensure that they correctly trigger changes without having

KnockOut.js With Asp.net mvc [closed]

断了今生、忘了曾经 提交于 2019-12-03 02:25:41
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 2 years ago . Just started learning the new asp.net mvc4 SPA template , noticed that knockout is being used , so give me reference to any book / Video which describes asp.net mvc with knockout.js from scratch . 回答1: A really good start is to work through the tutorials step by step on the knockoutjs.com site, the tutorials are

KnockOut.js With Asp.net mvc [closed]

北慕城南 提交于 2019-12-02 15:57:00
Just started learning the new asp.net mvc4 SPA template , noticed that knockout is being used , so give me reference to any book / Video which describes asp.net mvc with knockout.js from scratch . A really good start is to work through the tutorials step by step on the knockoutjs.com site, the tutorials are brilliantly put together and there are live examples which help to demonstrate "real world" scenarios. Once you are comfortable with the knockout constructs this article gives a basic but good illustration of integrating pure knockout with MVC controllers, models and views. An alternative

Converting circular structure to JSON in knockout js

北城余情 提交于 2019-12-02 09:50:42
I have two grid structure, In one of them I have multiple fields multiple times, whereas, in one I have two fields single time. I write apply method for each grid my first grid id working fine, but when I am clicking apply on second grid I am getting this error Uncaught TypeError: Converting circular structure to JSON Here are both the apply methods: self.applyRate = function (loan) { // commit the edit transaction self.editTransaction.notifySubscribers(null, "commit"); alert(ko.toJSON({data:loan})); // hides the edit fields self.editingItem(null); }; self.apply = function (data) { // commit

How to pass value from one view model to another viewmodel in knockout js?

≯℡__Kan透↙ 提交于 2019-12-01 22:51:04
i have two view models and i want to pass value from one view model to another viewmodel. i have two viewmodels and two div i want to display another div on click of button which is present in div 1. here is html code <div id="container1"> <ul > <li >Container1 item</li> <!-- ko foreach: myItems --> <li>Item <span data-bind="text: $data"></span></li> <!-- /ko --> </ul> <button data-bind="click:showDiv">show another div</button> </div> <div id="container2" data-bind="visible:show"> <ul> <li >Container2 item</li> <!-- ko foreach: myItems --> <li>Item <span data-bind="text: $data"></span></li> <!

dynamic column and rows with knockoutjs

孤人 提交于 2019-11-30 16:58:45
My input parameter for the code below is just a tablename, I was able to query the data return in json format, however, i am not able to display my rows item of data. any idea what did i do wrong? <script> var invtype = "@ViewBag.invtype"; function ViewModel() { var self = this; function ColName(tbstruct){ this.ColumnName = tbstruct.ColumnName } self.TBStruct = ko.observableArray(); self.items = ko.observableArray(); self.invtype = invtype; self.Load = function () { //expected data for self.items //[{"$id":"1","Id":2,"Inv_Id":"PV0001-1","ACX_No":"6","ACX_Name":"ABC","S_No":"5", "Acc_Class":

dynamic column and rows with knockoutjs

谁说我不能喝 提交于 2019-11-29 23:47:25
问题 My input parameter for the code below is just a tablename, I was able to query the data return in json format, however, i am not able to display my rows item of data. any idea what did i do wrong? <script> var invtype = "@ViewBag.invtype"; function ViewModel() { var self = this; function ColName(tbstruct){ this.ColumnName = tbstruct.ColumnName } self.TBStruct = ko.observableArray(); self.items = ko.observableArray(); self.invtype = invtype; self.Load = function () { //expected data for self