function tournamentViewModel(){ var self= this; self.name = ko.observable(); self.districts = ko.observableArray([new district('Provo',1),new district('Salt Lake City',2),new district('St. George',3)]); self.district = ko.observableArray(); self.regions = ko.observableArray([new region('Utah',1),new region('Idaho',2)]); self.region = ko.observableArray(); self.location = ko.observable(); self.date = ko.observable(); self.startTime = ko.observable(); self.image = ko.observable(); self.flyer = ko.computed(function(){return '<h1>'+self.name+'</h1>'+self.image},self); self.clearImage = function(){ self.image(''); } self.tournamentID = ko.computed(function(){return 't_'+self.district+'_'+self.region+'_'+self.date}, self); };
The above knockout.js view model seems fine, except when I want to associate something with a computed observable flyer . Instead, all I see is the following text:
<h1>function c(){if(0<arguments.length){if(!c.equalityComparer||!c.equalityComparer(d,arguments[0]))cI(),d=arguments[0],cH();return this}aULa(c);return d}</h1>function c(){if(0<arguments.length){if(!c.equalityComparer||!c.equalityComparer(d,arguments[0]))cI(),d=arguments[0],cH();return this}aULa(c);return d}
I do not know what is going on here. The following is the binding I am referring to. I tried both html and text bindings.
<span data-bind="text: flyer"></span>
The BTW computed observable tournamentID works fine, and the syntax seems identical. I think the problem arises when I use self.name in the computed observable. Any ideas?
source share