Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Select2 adds a title attribute to form controls

I'm using Select2 version 3.4.8 and have recently noticed that the code is adding a title attribute to each form control in my page, using the text of the associate label for the title. I assume the Select2 developers meant this as an accessibility improvement, but it is a dubious choice, as there already is an associated label.

I am looking for a way to disable this without patching select2.js directly. I've looked through the documentation and couldn't find anything. Is there a way to do this, or do I either have to patch select2.js (perhaps commenting out line 692) or write a few lines of script to remove title attributes after they've been added to .select2-container divs? (Or is this fixed in version 3.5.0?)

like image 514
Derek Henderson Avatar asked Jul 22 '14 16:07

Derek Henderson


1 Answers

When loading the page add the following script:

$(".select2-selection__rendered").removeAttr('title');

This will remove the title.

like image 78
Shano Avatar answered Nov 05 '22 15:11

Shano