angular-selectize icon indicating copy to clipboard operation
angular-selectize copied to clipboard

Doesn't trigger ng-touched

Open PaddyMann opened this issue 10 years ago • 4 comments

After the selectize input has been touched by the user (and a blur event triggered for the first time), it should be given the ng-touched css class and form.field.$touched should be set to true.

I've currently hacked this in using onblur, but would be great if it was fixed properly :)

PaddyMann avatar Feb 11 '15 12:02 PaddyMann

#58 think these might be related

geemang2000 avatar Mar 14 '15 16:03 geemang2000

Have the same issue PaddyMann can you detail how you hacked this using onblur ? Do you mean jquery ?

abariatti avatar Apr 08 '15 08:04 abariatti

Ok figured it out! Here is what I did based on PaddyMann comment :

$scope.mySelectizeConfig = {
// config options here
  onInitialize: function (selectize) {
    selectize.on('blur', function () {
      selectize.$control.addClass('ng-touched');
    });
  },
};

Would be nice to have it fixed though :-)

abariatti avatar Apr 08 '15 08:04 abariatti

Add this to the directive to set touch:

settings.onBlur = function(){
  selectize = element[0].selectize;
  if (scope.config.onBlur) {
    scope.config.onBlur(selectize);
  }
  scope.$apply(function(){modelCtrl.$setTouched();});
}

pouletfou avatar Jun 29 '17 20:06 pouletfou