Ketika menggunakan Select2 [1] dengan jQuery Validation [2] saya menemukan error :
" An invalid form control with name='' is not focusable."
Setelah googling sebentar saya menemukan jawabannya di [3][4].
Solusinya :
Tambahkan CSS berikut :
.select2-wrapper {
display: inline-block;
position: relative;
}
Kemudian ketika inisiasi select2, tambahkan attr seperti berikut :
$("#selector").select2({
placeholder: "Pilih",
allowClear: false
}).attr('style','display:block; position:absolute; bottom: 0; left: 0; clip:rect(0,0,0,0);');
Referensi
- Select2, The jQuery replacement for select boxes, https://select2.github.io/
- jQuery Validation Plugin, https://jqueryvalidation.org/
- How to use with a form validator? #584, https://github.com/select2/select2/issues/584
- fiddle How to use with a form validator, http://jsfiddle.net/q7kxsf17/10/
No comments:
Post a Comment