0

这是我正在谈论的网站:http: //imok.ro/demo/drtudor/index.php/our-practice/osteopathic-manual-medicine

它在 Joomla 2.5 上运行,但使用 Ajax(一个插件)加载。这个插件有一个“滚动到顶部”选项,但它与我添加的 jQuery 脚本冲突(用于自定义滚动)。

除了 jQuery 库之外,还加载了用于背景动画的“jquery.backgroundpos.js”,以及用于自定义滚动条的“jquery.mcustomscrollbar.concat.min.js”。

所以我决定自己做一个代码,它有两部分。我的问题是,他们不能一起工作......单独一切都很好。

(function(jQuery){
jQuery.noConflict();
    jQuery(window).load(function(){
        jQuery("#rt-mainbody").mCustomScrollbar({
            autoHideScrollbar:true,
            theme:"light-thin"  
        });
    });
})(jQuery);     

jQuery(document).ready(function() {
    jQuery('a').click(function(){
        jQuery('#rt-mainbody').animate({scrollTop:0}, 'slow');
            return false;
        });
});

我在这里想念什么?

编辑:

我还不是 Web 编程专家,也无法调试 mscustomscrollbar.js。我认为由于 Ajax 调用,我无法通过 Firebug 进行调试。(有没有我不知道的解决方案?)文件中的代码有 1000 行长,不知道要查找什么...

我继续寻找解决方案,发现这个插件还有很多其他功能,比如 ScrollTo 函数,或者.mCustomScrollbar("update"). 这并没有解决问题,所以我认为应该在重新加载页面后调用这个(“更新”)函数。在 Ajax 插件 index.php 中有一行在每个事件之后向上滚动页面。我在这里添加了“更新”功能,但由于某种原因它不起作用......这是用 Ajax 编写的,因此它与 jQuery 不兼容吗?

if($this->params->get('scrlUp', 1) == 1){
        //for nice scroll ;)
        JHTML::_('behavior.framework', true);
        $cnfg_data .= "\nFLAX.Html.onall('response', function(){new Fx.Scroll(
            document.getElementById('rt-mainbody')).toTop().mCustomScrollbar('update');    
        });";
    }

谢谢!

4

1 回答 1

0

第一个函数被立即调用,当 jQuery 可能还不可用时,我不确定挂钩到就绪和加载是否有意义,像这样调试它可能更容易:

jQuery(function($) {
    $("#rt-mainbody").mCustomScrollbar({
        autoHideScrollbar:true,
        theme:"light-thin"  
    });
    $('a').click(function(){
        $('#rt-mainbody').animate({scrollTop:0}, 'slow');
            return false;
        });
});

然后在你的 mCustomScrollbar 里面做一些 debug.log 看看它卡在哪里

于 2013-04-16T07:31:31.853 回答