Check Knockout and Twitter Twitter

I am trying to integrate knockout verification and twitter loading in this editor: http://jsfiddle.net/casudeo/Jbp7y/18

I would like to use twitter bootstrap css to input errors. To do this, I need to somehow "approach" the div of the control group and add the "error" class to it. Is there a way to achieve this without modifying the css files?

Further clarification due to the Dominican comment below: 1) Click the "Add" button to add a new item. 2) Try to save with empty values. 3) Validation of KO will catch invalid entries. However, I would also like to apply the "error" css class to highlight invalid fields.

+4
source share
1 answer

Here is the updated fiddle: http://jsfiddle.net/jearles/Jbp7y/147/

HTML

<div><button data-bind="click: clickMe">Click Me!</button></div> 

Js

 var ViewModel = function() { var self = this; self.clickMe = function(data,event) { var target; if (event.target) target = event.target; else if (event.srcElement) target = event.srcElement; if (target.nodeType == 3) // defeat Safari bug target = target.parentNode; target.parentNode.innerHTML = "something"; } } ko.applyBindings(new ViewModel()); 

What I changed:

  • Add validationElement bindings to control divs
  • Add when calling 'showAllMessages ()' when errors are detected
  • Make sure errorElementClass is set to 'error'
+7
source

All Articles