knockout.js - Add class through knockout if viewmodel property is not null -


i have view model property so

var customproperties = json.parse(this.model.get('customproperties')); viewmodel.clickeventaction = customproperties.clickeventaction; //returns string such "here" or "there" 

and trying see if exists in html , if assign class element. have click happen if not null cut down on click events called.

i have tried several different ways nothing seems work. like...

data-bind="class: {thisisclass: clickeventaction()}  data-bind="class: {thisisclass: clickeventaction}  data-bind="attr: {class: clickeventaction()}  data-bind="css: {thisisclass: clickeventaction() < 0} 

and i've tried several other ways, nothing seems want work.

since property not observable not function. can evaluate directly without "()".

data-bind="css: clickeventaction == null ? 'class-name' : '';" 

where "class-name" class want assign dom object.


Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

[C++][SFML 2.2] Strange Performance Issues - Moving Mouse Lowers CPU Usage -

ios - Possible to get UIButton sizeThatFits to work? -