cordova - error of using purecomputed function of knockoutjs in devextreme -


this dxview:- using knockoutjs in visual studio.

<div data-options="dxview : { name: 'home', title: 'home' } " >     <div class="home-view"  data-options="dxcontent : { targetplaceholder: 'content' } " >         <p>first name: <input data-bind="value: firstname" /></p>         <p>last name: <input data-bind="value: lastname" /></p>         <h2>hello, <span data-bind="text: fullname"> </span>!</h2>     </div> </div> 

this javascript in visual studio using devextreme:-

myfirstproject.home = function (params)  {     var viewmodel = function (first, last) {         this.firstname = ko.observable(first);         this.lastname = ko.observable(last);         this.fullname = ko.purecomputed(function ()         {             return this.firstname() + " " + this.lastname();          },this);    };    ko.applybindings(new viewmodel("planet", "earth"));     return viewmodel; }; 

this give while running program. error on purecomputed function of knockoutjs. not able understand why there error like:- error: 'uncaught typeerror: undefined not function', line 6, file 'http://localhost:51146/views/home.js'.

please tell me this. thank you.

you might have applied bindings in view multiple times. should bind viewmodel specific element. try doing this.

define id attribute div. example:

 <div id="one" data-options="dxview : { name: 'home', title: 'home' } " >  ko.applybindings(viewmodel, document.getelementbyid("one")); 

Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -