})
]));
+ sb.value = obj.value;
obj.parentNode.replaceChild(sb, obj);
}
saveValues: function(sb, ul) {
var sel = ul.querySelectorAll('li[selected]'),
div = sb.lastElementChild,
+ strval = '',
values = [];
while (div.lastElementChild)
if (s.hasAttribute('placeholder'))
return;
+ var v = {
+ text: s.innerText,
+ value: s.hasAttribute('data-value') ? s.getAttribute('data-value') : s.innerText,
+ element: s
+ };
+
div.appendChild(E('input', {
type: 'hidden',
name: s.hasAttribute('name') ? s.getAttribute('name') : (sb.getAttribute('name') || ''),
- value: s.hasAttribute('data-value') ? s.getAttribute('data-value') : s.innerText
+ value: v.value
}));
- values.push({
- text: s.innerText,
- value: s.hasAttribute('data-value') ? s.getAttribute('data-value') : s.innerText,
- element: s
- });
+ values.push(v);
+
+ strval += strval.length ? ' ' + v.value : v.value;
});
var detail = {
else
detail.value = values.length ? values[0] : null;
+ sb.value = strval;
+
sb.dispatchEvent(new CustomEvent('cbi-dropdown-change', {
bubbles: true,
detail: detail