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

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -