Open BlackBurnVP opened 2 years ago
Could you give me an example of what you would need?
I think he would like the attributes set against the regular options transferring to the equivalent "li". so when this is "converted" to a sumoselect: {select} {option data-whatever="test">option1{/option} {option data-something="else">option2{/option} {/select}
it ends up like this: {div class="optWrapper"} {ul class="options"} {li class="opt selected" data-whatever="test"}{label}option1{/label}{/li} {li class="opt" data-something="else"}{label}option2{/label}{/li} {/ul} {/div}
Yes. It's what I want to achieve. Thank you
I think he would like the attributes set against the regular options transferring to the equivalent "li". so when this is "converted" to a sumoselect: {select} {option data-whatever="test">option1{/option} {option data-something="else">option2{/option} {/select}
it ends up like this: {div class="optWrapper"} {ul class="options"} {li class="opt selected" data-whatever="test"}{label}option1{/label}{/li} {li class="opt" data-something="else"}{label}option2{/label}{/li} {/ul} {/div}
I see, I will handle this as soon as I have time
This would do it: in the createLi()...
I changed:
// AzzaAzza69 : create without any attributes (including class!)
const li = $(`<li><label>${opt.html()}</label></li>`);
// +AzzaAzza69 : copy all attributes from original option to new list item
for(attr of opt[0].attributes) {
li[0].setAttribute(attr.name, attr.value);
}
li[0].classList.add('opt');
...
// -AzzaAzza69 : new attribute copy will pull these across
// if (opt.attr('class'))
// li.addClass(opt.attr('class'));
// if (opt.attr('title'))
// li.attr('title', opt.attr('title'));
...
For now it's impossible to add some data attributes to select options. If we add it to html