asp.net mvc - breeze validationErrorsChanged don't work with custom validation -


in directive subscribe @ validationerrorschanged event. wwhen change data @ page. events works standart type validation.

standart required validation

<input class="form-control input-xs" type="text" required                        data-ng-model="item.description" data-entity-errors-indicator="item.description"> 

customer validation flowvalidation

div data-eve-compartment-and-technosphere-flow-selector="item"                         data-eve-compartment="compartment"                         data-eve-compartment-id="compartmentid"                         data-eve-technosphere-flow="technosphereflow"                         data-eve-technosphere-flow-id="technosphereflowid"                         data-eve-data-source="activitymodel.compartmentsandtechnosphereflows"                         class="pull-left"                         data-entity-errors-indicator="item:flowvalidation" />                 </td> 

dirictive

.directive('entityerrorsindicator', function () {     return {         restrict: 'a',         link: function (scope, element, attrs) {             var entity = scope.item;              var propertyname;              if (attrs.entityerrorsindicator && attrs.entityerrorsindicator.length > 0) {                 var item = attrs.entityerrorsindicator.split('.');                 var methodvalidate = attrs.entityerrorsindicator.split(':');                  if (item.length > 1) {                     propertyname = item[1];                 }                  if (methodvalidate.length > 1) {                     propertyname = methodvalidate[1];                 }             } else {                 propertyname = attrs.ngmodel.split('.')[1];             }              element.attr('data-html', 'true');              var unsubcribetokens;              unsubcribetokens = entity.entityaspect.validationerrorschanged.subscribe(function(event) {                 checkerrors();             });              checkerrors();              function checkerrors() {                 var err = [];                  entity.entityaspect.validateentity();                  if (propertyname != null) {                         _.each(entity.entityaspect.getvalidationerrors(), function(e) {                             var keyparts = e.key.split(':');                             if (keyparts[1] === propertyname) {                                 err.push(e);                             }                         });                 }                  var $parent = element[0].tagname == "span" || element[0].tagname == "div" ? element : element.parent();                  if (err.length > 0) {                     $parent.addclass('has-error');                     element.attr('data-original-title', geterrorshtml(err));                     element.tooltip('fixtitle');                 } else {                     $parent.removeclass('has-error');                     element.tooltip('hide').attr('data-original-title', null);                 }             }              function geterrorshtml(errors) {                 if (errors.length == 1) {                     return errors[0].errormessage;                 }                  var str = "<ul>";                 _.each(errors, function (error) {                     str += "<li>" + error.errormessage + "</li>";                 });                 str += "</ul>";                 return str;             }              scope.$on('$destroy', function () {                 if (unsubcribetokens != null) {                     entity.entityaspect.validationerrorschanged.unsubscribe(unsubcribetokens);                 }              });         }     }; }) 

sorry, can't validate this. have many custom validators , validations in our test suite , none exhibit behavior. take @ 'doccode' sample in breeze.js.samples github repo see examples of of these.

i think need isolate breeze validation code rest of ui verify this.

if still think have bug, create bug fails ( within doccode structure) , post code either here or add new issue 'breeze.js.samples' repo here:

https://github.com/breeze/breeze.js.samples


Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -