Created
February 12, 2023 10:40
-
-
Save valiantboymaksud/93b6d3fd83495aec495aa4cde86ad76a to your computer and use it in GitHub Desktop.
select2 add option with new keyword
This file contains hidden or 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
createTag: function (params) { | |
return { | |
id: params.term, | |
text: params.term, | |
newOption: true | |
} | |
}, | |
templateResult: function (data) { | |
var $result = $("<span></span>"); | |
$result.text(data.text); | |
if (data.newOption) { | |
$result.append(" <em class='text-danger'>(new)</em>"); | |
} | |
return $result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment