Last active
September 8, 2020 10:20
-
-
Save m8rge/61929a6c356349bf080c to your computer and use it in GitHub Desktop.
twitter bootstrap tooltip over select2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Declate title attribute on target select element. | |
* Initialize tooltip: | |
*/ | |
jQuery("div.select2-container").tooltip({ | |
title: function() { | |
return $(this).next().attr("title"); | |
}, | |
}); |
This does not work on select2's that use the ajax option to load your select2 data. This is because the ajax method (returns a div) does not use the same DOM nodes as a non-ajax select2 (returns a select) to create the select2. Anyone have code that supports tooltips on ajax-based select2's?
Using the latest bootstrap and select2. I can't get it working properly, it only works if I remove "div" and define "title" manually. However, defining title manually isn't a solution. Could someone help on this?
$(".select2-container").tooltip({
title: "abc",
});
Using tooltip semantic on the select element:
$("span.select2.select2-container").tooltip({
title: function() {
var title = $(this).prev().attr("data-original-title");
return title;
}
});
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You sir, are a lifesaver! Thanks!