i'm really looking for any kind of direction or help, in my code below, what kind of way i can do to make an action when the button "Add new item" is clicked.
$('#my_select').select2({
placeholder: 'Name',
tags : true,
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("<button class='add btn btn-secondary btn-sm ml-10'> + Add New Item</button>")
}
return $result;
},
});
thank's.
I see two approaches here: