You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Having a bit of trouble when the following conditions are present:
Have a pre-filled object; for example, if one were to make an 'Edit' form
Push the default object into the select list.
Set the ng-model field to the ID of the default object.
<!-- the mark-up --><selectizeng-model="base.serialnumber[data.linkfield]"
name="{{data.linkfield}}"
config="inputConfig"
options="cfg.sOpts"
ng-pattern="cfg.rx"
ng-required="cfg.required"></selectize>
/* the configuration */scope.inputConfig={create: true,valueField: attribs.valuefield,labelField: attribs.labelfield,searchField: attribs.searchfield,placeholder: attribs.placeholder,inputClass: 'form-control selectize-input',onInitialize: function(selectize){// receives the selectize object as an argumentselobj=selectize;},maxItems: 1,load: debounce(function(query,callback){if(!query.length)returncallback();if(query.length<attribs.minlen)returncallback();this.clearOptions();scope.cfg.queryFunction(query);},400,true)};
/* a bit of json as an example */{"Employee":
{"Id":4,"Name":"EMPLOYEE NAME"},"Id":20088,"SerialNumber":"123456","DateOfOrigination":"2015-12-12","EmployeeId":4}
At this point things look great. The options include the item that is required and the control shows the appropriate text.
The trouble sets in when adding ng-required='true'. Even though the control has been pre-populated, it will be in-valid until the user removes the pre-populated item and chooses the default option from the options list.
The text was updated successfully, but these errors were encountered:
varsetSelectizeValue=function(){validate();selectize.$control.toggleClass('ng-valid',modelCtrl.$valid);selectize.$control.toggleClass('ng-invalid',modelCtrl.$invalid);selectize.$control.toggleClass('ng-dirty',modelCtrl.$dirty);selectize.$control.toggleClass('ng-pristine',modelCtrl.$pristine);if(!angular.equals(selectize.items,scope.ngModel)){selectize.setValue(scope.ngModel,true);/* added the following line */if(!!scope.ngModel){modelCtrl.$setValidity('required',true);};}}
Having a bit of trouble when the following conditions are present:
At this point things look great. The options include the item that is required and the control shows the appropriate text.
The trouble sets in when adding ng-required='true'. Even though the control has been pre-populated, it will be in-valid until the user removes the pre-populated item and chooses the default option from the options list.
The text was updated successfully, but these errors were encountered: