Permalink
Browse files

feat(expandable): initialized state and function

  • Loading branch information...
ddprrt committed Aug 18, 2016
1 parent 2443329 commit 999525f3661ad7491f7302cc4dc0c09aad1321dd
Showing with 13 additions and 6 deletions.
  1. +13 −6 src/expandable/expandable.js
@@ -2,10 +2,17 @@ import $ from '../js-common-components/dollar';
const toggleClass = 'is-expanded';
$('.expandable__trigger').forEach(el => {
el.addEventListener('click', (ev) => {
ev.preventDefault();
ev.stopPropagation();
el.parentNode.classList.toggle(toggleClass);
const init = () => {
$('.expandable__trigger').forEach(el => {
if (!el.getAttribute('data-initialized')) {
el.addEventListener('click', (ev) => {
ev.preventDefault();
ev.stopPropagation();
el.parentNode.classList.toggle(toggleClass);
});
el.setAttribute('data-initialized', true);
}
});
});
};
init();

0 comments on commit 999525f

Please sign in to comment.