From fe5fef5644ac7fa97e128192e02398c50dd18f0a Mon Sep 17 00:00:00 2001 From: Shawn Larson Date: Thu, 30 Nov 2017 16:52:26 -0700 Subject: [PATCH 1/2] add init --- src/ng-selectize.component.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/ng-selectize.component.ts b/src/ng-selectize.component.ts index 065f6fb..62d36b6 100644 --- a/src/ng-selectize.component.ts +++ b/src/ng-selectize.component.ts @@ -46,6 +46,7 @@ export class NgSelectizeComponent implements OnInit, OnChanges, DoCheck, Control @Input() errorClass: string; @Output() onBlur: EventEmitter = new EventEmitter(false); + @Output() onInit: EventEmitter = new EventEmitter(false); @ViewChild('selectizeInput') selectizeInput: any; @@ -66,6 +67,7 @@ export class NgSelectizeComponent implements OnInit, OnChanges, DoCheck, Control this.selectize = $(this.selectizeInput.nativeElement).selectize(this.config)[0].selectize; this.selectize.on('change', this.onSelectizeValueChange.bind(this)); this.selectize.on('blur', this.onBlurEvent.bind(this)); + this.selectize.on('initialize', this.onInitializeEvent.bind(this)); this.updatePlaceholder(); this.onEnabledStatusChange(); @@ -135,6 +137,9 @@ export class NgSelectizeComponent implements OnInit, OnChanges, DoCheck, Control this.onBlur.emit(); this.evalHasError(); } + onInitializeEvent() { + this.onInit.emit(); + } onSelectizeOptGroupAdd(optgroup: any): void { this.selectize.addOptionGroup(optgroup[this.getOptgroupField()], optgroup); From 9b97b842de6df2fcd1be1623659a1292ee70b8bb Mon Sep 17 00:00:00 2001 From: Shawn Larson Date: Mon, 4 Dec 2017 13:12:19 -0700 Subject: [PATCH 2/2] onLoad event, set value before options loaded fix --- src/ng-selectize.component.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/ng-selectize.component.ts b/src/ng-selectize.component.ts index 62d36b6..d427290 100644 --- a/src/ng-selectize.component.ts +++ b/src/ng-selectize.component.ts @@ -46,7 +46,7 @@ export class NgSelectizeComponent implements OnInit, OnChanges, DoCheck, Control @Input() errorClass: string; @Output() onBlur: EventEmitter = new EventEmitter(false); - @Output() onInit: EventEmitter = new EventEmitter(false); + @Output() onLoad: EventEmitter = new EventEmitter(false); @ViewChild('selectizeInput') selectizeInput: any; @@ -67,7 +67,6 @@ export class NgSelectizeComponent implements OnInit, OnChanges, DoCheck, Control this.selectize = $(this.selectizeInput.nativeElement).selectize(this.config)[0].selectize; this.selectize.on('change', this.onSelectizeValueChange.bind(this)); this.selectize.on('blur', this.onBlurEvent.bind(this)); - this.selectize.on('initialize', this.onInitializeEvent.bind(this)); this.updatePlaceholder(); this.onEnabledStatusChange(); @@ -116,7 +115,9 @@ export class NgSelectizeComponent implements OnInit, OnChanges, DoCheck, Control this.onSelectizeOptionRemove(record.item); }); this.updatePlaceholder(); + this.selectize.setValue(this.value); this.evalHasError(); + this.onLoadEvent(); } private _applyOptionGroupChanges(changes: any): void { @@ -127,7 +128,9 @@ export class NgSelectizeComponent implements OnInit, OnChanges, DoCheck, Control this.onSelectizeOptGroupRemove(record.item); }); this.updatePlaceholder(); + this.selectize.setValue(this.value); this.evalHasError(); + this.onLoadEvent(); } onBlurEvent() { @@ -137,8 +140,8 @@ export class NgSelectizeComponent implements OnInit, OnChanges, DoCheck, Control this.onBlur.emit(); this.evalHasError(); } - onInitializeEvent() { - this.onInit.emit(); + onLoadEvent() { + this.onLoad.emit(); } onSelectizeOptGroupAdd(optgroup: any): void {