M
M
mills2018-12-11 14:50:23
JavaScript
mills, 2018-12-11 14:50:23

Articles for every tab, what's the problem?

Hello!
I make changes on the site, on the page univerokrug.hse.perm.ru/announces

window.events_page = 1;
function show_else_ann(page) {

    var tabidd = jQuery('[data-tabs="ANNOUNCE"] .current').data('tab'); 
    if ( jQuery('[data-tabs="ANNOUNCE"] #tabid' +tabidd+ '.current').data('tab') ) { 

    page = window.events_page + 1; 
    window.events_page = page; 

    console.log(window.events_page = page);

    } 

    $('.tabs_panel>A').click(function(){
      window.events_page = 1;
    });


  window.events_page = page;
    jQuery.ajax({
        url: '<?= SITE_TEMPLATE_PATH; ?>/ajax/announces.php',
        data: {
     page: page, 
     code: '<?= $IBLOCK_CODE; ?>',
     tab: jQuery('[data-tabs="ANNOUNCE"] .current').data('tab'), 
     per: <?= $PER; ?>, 
     date: 2, 
<?php
if (isset($QUESTION) and $QUESTION) { ?>
     question: 1,
<?php } ?>
     href: '/announces/' <?= (isset($_REQUEST['ID']) ? ', id: ' . (int)$_REQUEST['ID'] : ''); ?>},
        method: 'POST',
        dataType: 'JSON',
        success: function(data) {
            if (data.items) {
                var i = 0;
                for (i in data.items) {
                    var tabidfix = jQuery('[data-tabs="ANNOUNCE"] .current').data('tab');
          jQuery('#cann' +tabidfix+ ' .event_container_a').append(data.items[i]);
                }
                if (data.items.length != <?= $PER; ?>) {
                    jQuery('.show_else_a').hide();
        }
            }
            if (data.items.length == 0) {
                jQuery('.show_else_a').hide();
      } 
        }
    });

}


When opening all articles, the "Show more" button is hidden as expected, but when switching to another month, it does not appear anymore. I made that when you click on the month, the button would appear and made the articles roll back to the first articles.
The article refuses:
$('.tabs_panel>A').click(function(){
window.events_page = 1;
});


The button appears when you click on the month:
jQuery('.tabs_panel>A').click(function(){ 
    jQuery('.show_else_a').show(); 
    });


but the problem is if a person returns for a month where he has already opened all the articles, then when you click on "show more", the articles open again ...

How can I force the script so that the button appears and disappears from whether there are more articles or not ???

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Ainur Valiev, 2018-12-11
@vaajnur

The Show more button is only in the content of the active tab. How will she appear in another tab if she is not there? Each tab must have its own, otherwise everything will be shown, even where it is already hidden.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question