Re:Bootstrap 5 will remove jQuery as a dependency
by efdee on Wednesday February 13, 2019 @04:33AM
(#19151705)
> TypeError: $(...).forEach is not a function
And so it starts. jQuery uses .each, not .forEach. So you fix that. But stuff still doesn't work.
Right, because jQuery's .each passes the index as first parameter and the element as second (or this).
jQuery trips me every single time.
Re:Bootstrap 5 will remove jQuery as a dependency
by LorenzA on Wednesday February 13, 2019 @03:00AM
(#19151280)
document.querySelectorAll('.tpm_sensors').forEach((sensor) => {if (sensor.pressure < threshold) { fixBeforeIDie(); }});
Re:Bootstrap 5 will remove jQuery as a dependency
by phponpcp on Wednesday February 13, 2019 @09:29AM
(#19153305)
Then this breaks in older browsers because forEach isn't a method on a NodeList. So you have to polyfill in features to do [...document.querySelectorAll('.tpm_sensors')].forEach(...);
Re:Bootstrap 5 will remove jQuery as a dependency
by ulucs on Wednesday February 13, 2019 @03:59AM
(#19151552)
and you usually define $ and $$ as querySelector and querySelectorAll at the beginning of the file if you don't like writing them all out, so they're exactly the same length
Re:Bootstrap 5 will remove jQuery as a dependency
by IgorPartola on Wednesday February 13, 2019 @07:49AM
(#19152615)
I remember the mess that came before jQuery. This is quite literally what we did back then, just with a custom made snippet of JS for finding by id and by class. It sucked. I mean to me Bootstrap is just a black box library, I don’t care how it works as long as it does. But this is going to suck for those working on its code.
Re:Bootstrap 5 will remove jQuery as a dependency
by capsulecorp on Wednesday February 13, 2019 @01:15AM
(#19150877)
No need to load a slow bloated library. Learn modern DOM methods. Reading does wonders, my opinion.
$('.tpm_sensors').forEach(function(sensor) { if (sensor.pressure < threshold) fixBeforeIDie(); });
vs:
var tpm_sensors = document.getElementsByClassName('tpm_sensors'); for (var i = 0, len = tpm_sensors.length; i < len; i++) { var sensor = tpm_sensors[i]; if (sensor.pressure < threshold) fixBeforeIDie(); }