Permalink
Browse files

fix(select): updated js and html to have options directly in the html…

… and not loaded from a json
  • Loading branch information...
Freihofner, Katrin Freihofner, Katrin
Freihofner, Katrin authored and Freihofner, Katrin committed Jan 9, 2017
1 parent ddb0571 commit 6d08a1c712f9c4d604c452686d6506631b2550d7
Showing with 6 additions and 47 deletions.
  1. +0 −22 assets/data/select_data.json
  2. +6 −1 src/select/samples/00-standard.html
  3. +0 −23 src/select/select.js
  4. +0 −1 src/select/select.scss
@@ -1,22 +0,0 @@
{
"options": [
{
"value": "Papaya"
},
{
"value": "Banana"
},
{
"value": "Ananas"
},
{
"value": "Apple"
},
{
"value": "Kiwi"
},
{
"value": "Orange"
}
]
}
@@ -1,2 +1,7 @@
<label for="s1" class="label">Select</label>
<select class="select" id="s1"><option value="Select..." selected="selected">Select...</option></select>
<select class="select" id="s1">
<option value="Banana" selected="selected">Banana</option>
<option value="Ananas">Ananas</option>
<option value="Papaya">Papaya</option>
<option value="Kiwi">Kiwi</option>
</select>
View
@@ -1,26 +1,4 @@
import $ from '../js-common-components/dollar';
require('../js-common-components/accordion');
function fetchData(select) {
const rq = { url: '/assets/data/select_data.json',
onLoad: (e) => {
const options = (JSON.parse(e.target.responseText)).options;
for (let i = 0; i < options.length; i++) {
const opt = document.createElement('option');
opt.value = options[i].value;
opt.innerHTML = options[i].value;
select.add(opt);
}
},
};
const xhr = new XMLHttpRequest();
xhr.addEventListener('load', rq.onLoad.bind(this));
xhr.open('GET', rq.url);
xhr.send();
}
const initData = () => {
$('select').forEach(el => {
@@ -35,7 +13,6 @@ const initData = () => {
ev.stopPropagation();
el.classList.remove('is-expanded');
});
fetchData(el);
el.setAttribute('data-initialized', true);
}
});
View
@@ -20,7 +20,6 @@
text-align: left;
overflow: hidden;
width: 100%;
color: $gray-500;
background-color: #fff;
background-image: url(/assets/images/icons/icons_file_002_dropdownclosed_downwards.svg);
background-repeat: no-repeat;

0 comments on commit 6d08a1c

Please sign in to comment.