Sofyan Setiawan Sofyan Setiawan - 3 months ago 16x
jQuery Question

How to insert FontAwesome inside Select2

I have no idea how to insert fontawesome inside Select2. What should I add the CSS or JS in it? I have a view like below.

click :

Can anyone help me?


Based on my plugin WP Mobile Splash Page Editor, I made a quick fiddle:

function format(icon) {
    var originalOption = icon.element;
    return '<i class="fa ' + $(originalOption).data('icon') + '"></i> ' + icon.text;
    width: "100%",
    formatResult: format

Hope that helps ;)