diff --git a/src/demo/app/select/select.html b/src/demo/app/select/select.html index 48444e6a9..01daedf93 100644 --- a/src/demo/app/select/select.html +++ b/src/demo/app/select/select.html @@ -12,7 +12,7 @@ + label="Select estático" [required]="modelo2.required" [allowOther]="true"> { + const n = { + [this.idField]: input, + [this.labelField]: input, + other: true + }; + this.data.push(n); + return n; + }), // dropdownParent: 'body', render: { - option: (item, escape) => '
' + escape(this.renderOption(item, this.labelField)) + '
', + option: (item, escape) => `
${escape(this.renderOption(item, this.labelField))}
`, item: (item, escape) => { if (this.multiple) { - return '
' + escape(this.renderOption(item, this.labelField)) + '
'; + return `
${escape(this.renderOption(item, this.labelField))}
`; } else { - return '
' + escape(this.renderOption(item, this.labelField)) + '
'; + return `
${escape(this.renderOption(item, this.labelField))}
`; } }, + option_create: (item, escape) => { + if (this.selectize.currentResults.items.length) { + return null; + } + return `

No figura en el listado, deseo agregar ${escape(item.input)} de todos modos.

`; + + } }, load: this.hasStaticData ? null : (query: string, callback: any) => { // Esta función se ejecuta si preload = true o cuando el usuario escribe en el combo @@ -272,6 +291,7 @@ export class PlexSelectComponent implements AfterViewInit, ControlValueAccessor }); }, onChange: (value) => { + // Busca en la lista de items un valor que coincida con la clave if (this.multiple) { let result = [];