Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Unable to process binding
Message
 
À
02/07/2014 08:01:14
Information générale
Forum:
Javascript
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01603075
Message ID:
01603257
Vues:
54
If it's a property you need RunSheetDetailFilter().searchText as the expression with Knockout.

Common mistake and one of the reasons I've abandoned Knockout sometime back for Angular.

+++ Rick ---

>Hi,
>
>first attempt at digging into some slightly complex javascript. I am getting this error:
>
>
Uncaught ReferenceError: Unable to process binding "value: function (){return RunSheetDetailFilter.searchText }"
>
>Not getting much hits when searching on this.
>
>Basically it sounds as if the function has not been defined correctly.
>
>This is the code in my cshtml file:
>
>
<input class="filter-box"
>           data-bind="value: RunSheetDetailFilter.searchText, valueUpdate: 'afterkeydown', escape: clearFilter"
>           placeholder="Filter by AWB#" type="text" />
>
>This is my filter.runsheetdetail.js file (I am following an example that uses require.js):
>
>
define('filter.runsheetdetails',
>    ['ko', 'utils', 'config'],
>    function (ko, utils, config) {
>
>    	var RunSheetDetailFilter = function () {
>    		var self = this;
>    		self.searchText = ko.observable().extend({ throttle: config.throttle });
>    		return self;
>    	};
>
>    	RunSheetDetailFilter.prototype = function () {
>    		var tagDelimiter = '|',
>                escapedTagDelimiter = '\\|',
>                searchTest = function (searchText, runsheetdetail) {
>                	if (!searchText) return true; // always succeeds if no search text
>                	var srch = utils.regExEscape(searchText.toLowerCase());
>                	if (runsheetdetail.awb_number().toLowerCase().search(srch) !== -1) return true;
>                	return false;
>                },
>
>                predicate = function (self, runsheetdetail) {
>                	// Return true if all of these meet the filter criteria. Otherwise, return false
>                	var match = searchTest(self.searchText(), runsheetdetail);
>                	return match;
>
>                	//PAPA: testing only. 
>                	//var matchSearch = searchTest(self.searchText(), session),
>                	//    matchFav = favoriteTest(self.favoriteOnly(), session),
>                	//    matchTime = timeSlotTest(self.minDate(), self.maxDate(), session),
>                	//    matchModels = modelTest(self.timeslot(), self.speaker(), self.track(), session);
>                	//console.log('search filter matched: ' + matchSearch);
>                	//console.log('favorites filter matched: ' + matchFav);
>                	//console.log('time filter matched: ' + matchTime);
>                	//console.log('models filter matched: ' + matchModels);
>                	//console.log('MATCH === ' + matchSearch && matchFav && matchTime && matchModels);
>                	//return matchSearch && matchFav && matchTime && matchModels;
>                };
>
>    		return {
>    			predicate: predicate
>    		};
>    	}();
>
>    	return RunSheetDetailFilter;
>    });
>
>Can anyone spot anything wrong in there?
+++ Rick ---

West Wind Technologies
Maui, Hawaii

west-wind.com/
West Wind Message Board
Rick's Web Log
Markdown Monster
---
Making waves on the Web

Where do you want to surf today?
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform