会议网站活动安排行为



我正在建立一个会议网站,日程安排中有一些并发会议。正如您在屏幕截图中看到的,研讨会 3 应该与研讨会 1 和 2 同时进行,但它们是分开的。请在下面找到相关代码。谁能说出原因可能是什么?

我网站上的活动时间表截图

_addNewContent = function (msg) {
    var lastBlock = false;
    var lastConcurrent = false;
    if (_page == 1) {
        _wrapper.html('');
    }
    $.each(msg.sessions, function (i) {
        if (lastBlock) {
            var lastTime = lastBlock.find('.schedule__time').text();
            lastTime = lastTime.split('-');
            if ($.trim(lastTime[0]) == this.time) {
                if (!lastConcurrent) {
                    lastConcurrent = $('<div class="schedule__concurrent"></div>').appendTo(_wrapper);
                }
                lastConcurrent.append(lastBlock);
            } else {
                if (lastConcurrent) {
                    lastConcurrent.append(lastBlock);
                    lastConcurrent = false;
                } else {
                    _wrapper.append(lastBlock);
                }
            }
        }
        var newBlockString = '<div class="schedule__item ' + _dropdown + ' more-content__item">' +
                '<time class="schedule__time" datetime="' + this.time + '">' + this.time + ' - ' + this.end_time + '</time>' +
                '<h2 class="schedule__event">' + this.post_title + '</h2>' +
                '<div class="schedule__details">';
        if (_dropdown) {
            newBlockString += ' <a class="schedule__close" href="#"><i class="fa fa-times"></i></a>';
        }
        newBlockString += '<a href="#" class="schedule__main-place"><i class="fa fa-location-arrow"></i> ' + this.location + '</a>' +
                '<div class="schedule__layout">' +
                '<div class="schedule__speakers-group">'; // schedule__speakers-group
        $.each(this.speakers, function () {
            var speaker_image = '';
            if (typeof (this.post_image[0]) !== 'undefined') {
                speaker_image = 'background-image: url(' + this.post_image[0] + ')';
            }
            var favourite = this.featured ? 'speakers-favorite speakers-favorite_small' : '';
            newBlockString += '<a href="' + this.url + '" class="schedule__speaker">' + // schedule__speaker
                    '<div class="schedule__speaker-pic ' + favourite + '" style="' + speaker_image + '">' +
                    '<span class="schedule__speaker-hover">' + msg.strings.view_profile + '</span>' +
                    '</div>' +
                    '<h3 class="schedule__speaker-name">' + this.post_title + '</h3>' +
                    '</a>'; // /schedule__speaker
        });
        newBlockString += '</div>' + // /schedule__speakers-group
                '<div class="schedule__info">' +
                '<div class="schedule__text">' + this.post_excerpt + '</div>' +
                '<div class="schedule__labels">';
        $.each(this.tracks, function () {
            newBlockString += '<span class="label" style="background-color:' + this.color + ';">' +
                    this.name +
                    '</span> ';
        });
        newBlockString += '</div>' +
                '<a href="' + this.url + '" class="btn btn_7">' + msg.strings.more_info + '</a>' +
                '</div>' + // /schedule__info
                '</div>' + // /schedule__layout
                '</div>' + // /schedule__details
                '</div>'; // /schedule__item
        var newBlock = $(newBlockString);
        if (msg.sessions.length == 1 || msg.sessions.length == i + 1) {
            _wrapper.append(newBlock);
        }
        lastBlock = newBlock;
    });
    var newItems = _wrapper.find('.hidden');
    setTimeout(function () {
        $.each($('.schedule__items'), function () {
            new ScheduleOpen($(this));
        });
    }, 10);
    setTimeout(function () {
        _heightAnimation(msg.has_items, newItems);
    }, 50);
},

我想您的网站在运行整个功能之前首先阅读了一系列会议会话。

我找到了这部分

if (msg.sessions.length == 1 || msg.sessions.length == i + 1) {
        _wrapper.append(newBlock);
    }

可能会阻止某些会议会话与上一个会议会话并发,尤其是最后一个阵列项目。

您可以将其更改为

if (msg.sessions.length == 1) {
    _wrapper.append(newBlock);
}
if (msg.sessions.length == i + 1) {
    if (lastConcurrent) {
        lastConcurrent.append(newBlock);
    } else {
        _wrapper.append(newBlock);
    }
}

最新更新