html - Select2 formatResult get attributes of option -
get custom data-attribute in select2 <select>
we need same thing specified in above link. but, how attributes of option element in formatresult function?
you try following code :
$select2.data('placeholder', 'please choose').html(_options).select2({ formatnomatches: function (term) { return 'there no "' + term + '" item'; }, formatresult: function(term) { return $(term.element).data('cnt'); }, allowclear: true });
Comments
Post a Comment