本文介绍了我是如何在Kncokout中获得更改文本框的价值的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我有两个文本框。一个是雇员,另一个是工作时间。 employeename已预先填好。我必须为每个员工节省工作时间,我必须在javascript中获得工作时间并保存它们。我正在使用淘汰赛。每行都会有一个保存按钮。 如何在保存后从texbox获取更改后的工作时间? UI(UserInterface) I have to two textboxes. One is employeename and other is worked hours. employeename is already prefilled. I have to save work hours for each employee, I have to get the work hours in javascript and save them. I am using knockout. There will be a save button for each row.How to get the changed worked hours from the texbox after they hit save?UI(UserInterface)<tbody data-bind="foreach: arraytoadd"><tr> <td data-bind="text: employeename"></td> <td>&lt;input id="indynamicntendtime" data-bind="text: workedhours"/&gt;</td> <td> &lt;input type="button" id="btnsave" value="save"/&gt; </td> </tr></tbody> Javascript JavascriptTemplatefunction = function(){ var self = this; self.employeename = ko.observavle(""); self.workedhours = ko.observale("");}RealFunciton = function(){ ver self = this; self.arrarytoadd = ko.obeservablearray(); self.addevent = function () { self.arraytoadd.push( new Templatefunction); }} 从Ajax获取值并分配 Getting the values from Ajax and assigning for(var i=0;i&lt;response.d.length;i++)&gt; { var x = new TemplateFunction(); x.employeename(response.d[i].EmployeeName); x.workedhours(response.d[i].ActualContractorEndTime); jobactivityVM.arraytoadd.push(x); }//TO DO SAVE FUNCIONALITY. On every row save button click i have to get the corresponding workhours $(document).on("click", "[id*=btnsave]", function (e) { var x = new TemplateFunction(); var contractorstarttime = Templatefunction["workedhours"]; //HOW TO GET THE CHANGED WORKED HOURS . //start initialising the parameters needed for the ajax call var params = {}; params.workedhours=workedhours; }); 推荐答案 这篇关于我是如何在Kncokout中获得更改文本框的价值的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-26 18:13