Highlight selected row using knockout

前端 未结 2 1588
说谎
说谎 2021-01-24 20:50

With reference to below question asked in stackoverflow

Display clicked item

I have modified the fiddle created by john papa. Here is my updated fiddle

2条回答
  •  清酒与你
    2021-01-24 21:03

    If you click on the New button you will see the following error in your browser javascript console:

    Uncaught ReferenceError: item is not defined

    Because you don't have item in your method. In your case the item should be the newly created Thing so store it in a variable which you can name item and it will work fine.

    this.NewDetail = function(){
        var item = new Thing(4, "Thing 4", self.model.CurrentDisplayThing);
        self.model.Things.push(item);
        self.model.CurrentDisplayThing(item);
      };
    

    Here is an updated JSFIddle.

提交回复
热议问题