OWL轮播同步与Ajax之间发生冲突。仅用于第三张幻灯片

我使用猫头鹰转盘2.3.4和使用按钮滑动转盘的同步方法。 每张幻灯片都包含循环WP帖子(标题,图像和类别)。 滑块上方有我的按钮(帖子类别),对应于同步2。 如果我单击某个帖子,则会在ajax中调用它,然后出现一个窗口并显示全部内容。

问题仅在第三张幻灯片上: 如果我使用mousedrag转到第三张幻灯片并单击任何帖子,则所有工作罚款都将以ajax调用。 如果我单击第三个按钮(同步2,以显示第三张幻灯片),然后单击任何帖子,则ajax不会调用这些帖子,而是打开一个新的浏览器标签。

这是我的ajax请求来调用帖子内容:

(function($) {
$(document).ready(function() {
$('.post-link').click(function(event) {
      var post_id = $(this).attr("id");
      event.preventDefault();
      $.post(
            ajaxurl,{'action': 'more_content','the_ID': post_id},function( data ) { $('#window-post').html(data); }
      );
 });$('.win-post').on('click','.im-x-mark',function(){
    $("#window-post").html("");
});
});
})(jQuery);

这是OWL轮播同步代码:

var sl = jQuery.noConflict();
sl(document).ready(function() {
var sync1 = sl("#slide-appareil");
var sync2 = sl("#nav-appareil");
var slidesPerPage = 3; //globaly define number of elements per page
var syncedSecondary = true;

sync1.owlCarousel({
    items: 1,slideSpeed: 2000,dots:false,nav:false,loop : true
}).on('changed.owl.carousel',syncPosition);

sync2
    .on('initialized.owl.carousel',function() {
        sync2.find(".owl-item").eq(0).addClass("current");
    })
    .owlCarousel({
        items: slidesPerPage,smartSpeed: 200,slideSpeed: 500,slideBy: slidesPerPage,responsiveRefreshRate: 100,touchDrag  : false
    }).on('changed.owl.carousel',syncPosition2);

function syncPosition(el) {
    //if you set loop to false,you have to restore this next line
    //var current = el.item.index;

    //if you disable loop you have to comment this block
    var count = el.item.count - 1;
    var current = Math.round(el.item.index - (el.item.count / 2) - .5);

    if (current < 0) {
        current = count;
    }
    if (current > count) {
        current = 0;
    }

    //end block

    sync2
        .find(".owl-item")
        .removeclass("current")
        .eq(current)
        .addClass("current");
    var onscreen = sync2.find('.owl-item.active').length - 1;
    var start = sync2.find('.owl-item.active').first().index();
    var end = sync2.find('.owl-item.active').last().index();

    if (current > end) {
        sync2.data('owl.carousel').to(current,100,true);
    }
    if (current < start) {
        sync2.data('owl.carousel').to(current - onscreen,true);
    }
}

function syncPosition2(el) {
    if (syncedSecondary) {
        var number = el.item.index;
        sync1.data('owl.carousel').to(number,true);
    }
}

sync2.on("click",".owl-item",function(e) {
    e.preventDefault();
    var number = sl(this).index();
    sync1.data('owl.carousel').to(number,300,true);
});
});
dd56100 回答:OWL轮播同步与Ajax之间发生冲突。仅用于第三张幻灯片

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/2642935.html

大家都在问