![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/walla3t.corals.io/wp-content/plugins/meta-box/js/ |
/** * Link: https://stackoverflow.com/questions/37386293/how-to-add-icon-in-select2 */ ( function ( $, rwmb ) { 'use strict'; const template = option => { if ( option.text.includes( '<svg' ) ) { const title = option.text.replace( /<svg.*?>.*?<\/svg>/, '' ); return $( `<span class="rwmb-icon-select" title="${ title }">${ option.text }</span>` ); } return option.id ? $( `<span class="rwmb-icon-select" title=${ option.text }><i class="${ option.id }"></i>${ option.text }</span>` ) : option.text; }; function initIconField( event, options ) { $( this ).select2( { ...options, templateResult: template, templateSelection: template, } ); } rwmb.$document .on( 'init_icon_field', '.rwmb-icon', initIconField ); } )( jQuery, rwmb );