Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let catalog = [];
- let catalogTitle = [];
- if (JSON.parse(localStorage.getItem('requested-catalog-id')) != null) {
- catalog = JSON.parse(localStorage.getItem('requested-catalog-id'));
- catalogTitle = JSON.parse(localStorage.getItem('requested-catalog-title'));
- }
- $('.catalog .box-item .box-heading input[type=checkbox]').on('change', function () {
- // Dini ngalih ID ne bli, sing ngidang ngalih uli luar
- let $check = $(this); // Ne current checkbox ne;
- let $boxHeading = $check.closest('.box-heading'); // Ne box heading ane alih bli, sesuaikan jak DOM bli ditu.
- let id = $boxHeading.attr('data-catalog-id'); // Ne ID ne.
- let title = $boxHeading.attr('data-catalog-title'); // Ne Title ne.
- let showBigCheckBox = $(".catalog .box-heading span#" + id);
- // let checked = !!$check.val();
- let valueChecked = $check.val();
- let checked = valueChecked === $check.val();
- console.log(checked);
- if (checked) {
- if (catalog.length >= 3) {
- $('#staticBackdrop').modal({
- keyboard: false,
- static: true,
- focus: true,
- show: true,
- });
- return false;
- } else {
- catalog.push(id);
- catalogTitle.push(title);
- localStorage.setItem('requested-catalog-id', JSON.stringify(catalog));
- localStorage.setItem('requested-catalog-title', JSON.stringify(catalogTitle));
- showBigCheckBox.addClass('selected');
- }
- } else {
- catalog.splice($.inArray(id, catalog), 1);
- catalogTitle.splice($.inArray(title, catalogTitle), 1);
- localStorage.setItem('requested-catalog-id', JSON.stringify(catalog));
- localStorage.setItem('requested-catalog-title', JSON.stringify(catalogTitle));
- showBigCheckBox.removeClass('selected');
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement