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
http://jsfiddle.net/6FCEe/31/
I have added New button and clicking on it i push new record.In click event of New button i have added below code
this.NewDetail = function(){
self.model.Things.push(new Thing(4, "Thing 4", self.model.CurrentDisplayThing)
);
self.model.CurrentDisplayThing(item);
};
But the new row doesnt show as higlighted. What should i do to make it highlighted. The new row added should be shown as higlighted in yellow color.
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.
Just trivial bug
this.NewDetail = function(){
var item = new Thing(4, "Thing 4", self.model.CurrentDisplayThing);
self.model.Things.push(item);
self.model.CurrentDisplayThing(item);
};