Created
September 20, 2013 17:08
-
-
Save simevidas/6640655 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Page 3 | |
document.addEventListener('DOMContentLoaded', function init() { | |
var testD = document.querySelector('#testDetails'); | |
var summary = testD.querySelector('summary'); | |
summary.addEventListener('click', function () { | |
var open = !testD.hasAttribute('open'); | |
console.log(open); | |
}, false); | |
}); | |
// Page 4 | |
$(function () { | |
var testD = $('#testDetails'); | |
var summary = $('summary', testD); | |
summary.on('click', function () { | |
var open = !testD.attr('open'); | |
var loaded = testD.data('loaded'); | |
var url; | |
if (open && !loaded) { | |
testD.data('loaded', true); | |
url = testD.data('details'); | |
$.get(url).then(function (res) { | |
$(summary).after(res); | |
}); | |
} | |
}); | |
}); |
testing gist notifications, but everything is wrong in this 2013 gist anyway :D (take this with hirony)
- tabs are disturbing
addEventListener('DOMContentLoaded', ...)
works too, no need to usedocument
- the global selector, since there is an ID involved, is a bit LOL, 'cause any ID is reflected in the window object, so that
testDetails
would be already available - jQuery is disturbing in 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Improvements in Page 3 code:
Improvements in Page 4 code:
element anyways.)