core/jQuery.once is being deprecated in core.
https://www.drupal.org/node/3158256
1 Need help rewriting some lines of code using the core/once library.
Old:
$('.hub-recettes').find('input').once('recomandation-filter').on('ifChecked ifUnchecked', function (event) {
$('#views-exposed-form-hub-recette-page-1').submit();
});
New:
const filterElements = $(once('recommandation-filter', $('.hub-recettes').find('input:checkbox')));
filterElements.on('ifChecked ifUnchecked', function (event) {
$('#views-exposed-form-hub-recette-page-1').submit();
});
The new code is not working when the checkbox is checked or unchecked. I can't seem to find a solution to this.
Checkboxes on this page is transformed using the icheck library.
Any ideas ?
Comments
I hadn't realized they
I hadn't realized they deprecate $.once(), so my comment below is an educated guess.
It looks like this:
Is supposed to be this:
Contact me to contract me for D7 -> D10/11 migrations.
Thank you Jaypan,
Thank you Jaypan,
Final code:
const filterElements = once('recommandation-filter', '.hub-recettes');$(filterElements).on('ifChecked ifUnchecked', 'input:checkbox', function (event) {
$('#views-exposed-form-hub-recette-page-1').submit();
});
hmm.. I recently wrote some
hmm.. I recently wrote some code using .once too
$('div.mydiv').once('myotherdiv').each(function () {
can it simply be replaced with .. err...
is that correct?