Skip to content

Commit

Permalink
chore: clean up button JS demo + toggle theme class on the page to ma…
Browse files Browse the repository at this point in the history
…ke it easier to check that the demo is working as expected.
  • Loading branch information
bolt-bot committed Oct 23, 2018
1 parent 14c89ed commit eb97357
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
"theme:": "xdark",
"text": "XDark Button w/ External JS Example",
attributes: {
class: "js-button-theme-xdark",
class: [
"js-button-theme-xdark"
]
}
} %}
{% endblock %}
Expand All @@ -19,7 +21,7 @@
var elementBeingTargeted = 'button';
var selector;
if (element._wasInitiallyRendered){
if (element._wasInitiallyRendered === true){
setupEventListener(false);
} else {
element.addEventListener('rendered', setupEventListener);
Expand All @@ -31,10 +33,11 @@
} else {
selector = element.querySelector(elementBeingTargeted);
}
ready();
if (removeEventListener){
element.removeEventListener("rendered", setupEventListener, true);
element.removeEventListener('rendered', setupEventListener, true);
}
}
Expand All @@ -49,6 +52,6 @@
function buttonClicked(){
console.log('the button tag inside the rendered xdark bolt-button was clicked!');
document.body.classList.toggle('t-bolt-xdark');
}
</script>

0 comments on commit eb97357

Please sign in to comment.