user647314
user647314

Reputation: 327

knockout multiple settings in data-bind tag (attr and style)

Till the "style: {" the syntax is good, what is wrong with 2nd part ?

<div data-bind="attr: { 'style': 'position:relative; float:left; width: ' + width + 
'; height: ' + height + ';} style: {border: $parent.foo() ? \'1px solid black\' : \'1px solid white\' }'">

Thanks in advance Cs

Upvotes: 1

Views: 504

Answers (1)

Wayne Ellery
Wayne Ellery

Reputation: 7958

You don't need to use string concatenation for the model values. You are also missing a single quote at the end of the first style value and a comma at then end of the attr value:

<div data-bind="attr: { 'style': 'position:relative; float:left; width: width; height: height; '}, style: {border: $parent.foo() ? '1px solid black' : '1px solid white' }">

JsFiddle

Upvotes: 3

Related Questions