I'm attempting to implement a package called Sumoselect for a dropdown that I have. It's pulling in data that I'm able to see in the console.
There are two major issues that I'm having:
The dropdown doesn't appear properly---by default it's rendering as a square. The square appears in the pic below.
When you type a letter into the dropdown you do see the data, but only one letter appears at a time. Here's a pic
Each letter/character from the data set is getting added to its own div (to the attribute).
I can't tell if there's an issue with how I've set up Sumoselect or if it's something else.
At first I was only using the package jQuery Autocomplete. I'm not sure if I'm supposed to have Sumoselect alongside it or if I only need Sumoselect by itself.
JS snippet:
import "jquery-autocomplete/jquery.autocomplete.css";
import "sumoselect/sumoselect.css";
import "jquery";
import "jquery-autocomplete/jquery.autocomplete.js";
import "sumoselect/jquery.sumoselect.js";
// initialization async IIFE
(async function() {
const dataObj = await dataObjProm;
console.log( dataObj);
const table = new Table("table", dataObj.getRawData()),
chipSet = new ChipSet("departments-chip-set", dataObj.getDepartments()), // ------- this is where the data comes in
searchHandler = initSearchHandler(chipSet, table);
loadCombobox(dataObj.getDepartments());
// doSumo(dataObj.getDepartments());
// more code
function loadCombobox(chipSet) {
$('#combobox').autocomplete({
source: chipSet // how the data enters jQuery Autocomplete -------- I didn't see where to do this in Sumoselect, so I thought I needed to use both
}).on("click", function() {
console.log('cs: ' + chipSet)
console.log("combobox clicked")
});
doSumo(chipSet); // ----- not sure if this right here is correct
}
function doSumo(_target, chipSet) {
if($(_target).html().length <= 0) {
$(_target).append(chipSet.map(function(v){
return "<option title='" + v + "'>" + v + "</option>";
}).join(" "));
$("#combobox").SumoSelect({
okCancelInMulti: true,
search: true,
selectAll: true
});
$('.btnOk').on('click', function() {
var obj = [],
items = '';
$('#combobox option:selected').each(function(i) {
obj.push($(this).val());
$('#combobox')[0].sumo.unSelectItem(i);
});
for(var i=0;i<obj.length;i++) {items += ' ' + obj[i]};
alert(items);
});
}
}
html:
<select multiple="multiple" id="combobox" placeholder="Browse">
</select>
This happens because the parent container width is less and the texts inside the dropdown is applied a
word-break.The possible solution is to increase the available parent width so that even when the work breaks, its readable. See the example below with less width and normal.