Edit item in knockout observableArray

拟墨画扇 提交于 2019-12-31 03:42:07

问题


I am looking for an example where i can show an observableArray as normal text with edit / delete links. Items can be added/edited from a separate form. I am not able to edit the record from edit link it add new record!

 self.editItem = function (p) {
        //edit code
        ////???????
    };

Here is example


回答1:


As other mentioned in there answers, you should use with binding for editing any particular record. Here i have created a demonstration according to your need.

http://jsfiddle.net/85afB/1/




回答2:


You have to track the particular item which is going to be edit (have it observable) and use with binding. See full example in this answer (jsFiddle).




回答3:


Not completely sure what you are asking but if you are wanting to put the values back into the edit boxes then try this:

self.editItem = function (p) {
    self.FirstName(p.FirstName);
};

Will then just have to write your logic to check if it already exists



来源:https://stackoverflow.com/questions/15365227/edit-item-in-knockout-observablearray

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!