knockout.js - Knockout observable variable not changing its value on click -


I do not know why my currentTitle is not changing on click

  viewModel = {article: ko.observableArray ([{id: 1, title: "Article One", Content: "Content for an article."}, {ID: 2, Title: "Article two" Content: "Content for article two."}, {ID: 3, title: "Article three", content: "Content for article three."}})), Currenttitle: korseous ("old")} ; & Lt; Div data-bind = "foreach: viewModel.articles ()" & gt; & Lt; div data-bind = "text: title, click: getTitle" & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; div data-bound = "text: visualmodel.crtitle" & gt; & Lt; / Div & gt; getTitle = function () {viewModel.currentTitle = "title"; } Ko.applyBindings (viewModel);   

My code was posted here:

Your getTitle

Try:

  getTitle = function () {viewModel.currentTitle ("title");  

}

Comments

Popular posts from this blog

python - Writing Greek in matplotlib labels, titles -

c# - LINQ to Entities does not recognize the method 'Int32 IndexOf(System.String, System.StringComparison)' method -

Pygame memory leak with transform.flip -