Tell me more ×
Code Review Stack Exchange is a question and answer site for peer programmer code reviews. It's 100% free, no registration required.

In his KnockoutJs 1.3 beta post, Steve Sanderson has an example of using Binding providers ("5. Binding providers (and hence external bindings)") where he makes a comment in the JSFiddle JavaScript tab that says "// This syntax would be way more succinct with CoffeeScript".

How would this actually be accomplished?

// This syntax would be way more succinct with CoffeeScript
ko.bindingConventions.conventions(".person-editor", {
    ".person-editor"  : { 'with': myViewModel.person },
    ".first-name"     : function(person) { return { value: person.firstName } },
    ".last-name"      : function(person) { return { value: person.lastName } }
});

ko.bindingConventions.conventions("#weather-list", {
    "#weather-list"    : { 'with': myViewModel.weather },
    ".cities-list"     : function(weather) { return { foreach: weather.cities } },  
    ".city"            : function(item) { return { text: item.city } },      
    ".temp"            : function(item) { return { text: item.temperature } },        
    ".add-city"        : { click: function() { this.addItem() } }  
});
share|improve this question

1 Answer

up vote 1 down vote accepted
 ko.bindingConvenrions.conventions ".person-editor"
   ".person-editor"  :  
      'with'   :  myViewModel.person
   ".first-name"     : ( person ) ->
                        value : person.firstName
   ".last-name"      : ( person ) ->
                        value : person.lastName
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.