Closed karthiknamburu closed 2 years ago
Do you need to replace it with your method? Try:
$('input').on("itemAdded", function(e){
sort($(this).prev()); //---> ".bootstrap-tagsinput"
});
$('input').tagsinput();
function sort(ctrl){
var words = [];
ctrl.find(".tag").each(function(e){
words.push($(this).text()); //-- catch
})
words = words.sort(); //--- sort.
for(x=0; x <=words.length; x++){
var text = $(ctrl).find(".tag").eq(x).text(); //-- text original
var replace = $(ctrl).find(".tag").eq(x).html(); //-- text to replace
if (replace != undefined){
replace = $(ctrl).find(".tag").eq(x).html().replace(text, words[x]); //-- replace text
$(ctrl).find(".tag").eq(x).html(replace); //-- write
}
}
}
Hi, we are using bootstrap-tagsinput v0.8.0 in which the default sort in alphabetical order.
can i override this?