简体   繁体   English

JscrollPane无法正确加载到div中

[英]JscrollPane not loading into div properly

I'm having an issue with jscrollpane loading into a div using the following function: 我在使用以下功能将jscrollpane加载到div时遇到问题:

$(document).ready(function() {
  $("#shopping").click(function(event){
       $('#stage').hide();
      $('#stage').load('pages/shopping.html', {}, function() { $(this).fadeIn(800); });

The above code is on the index page and I'm calling up the "shopping page" as you can see above. 上面的代码位于索引页面上,正如上面所看到的,我在调用“购物页面”。 I have four other links that call up pages, one page has a slideshow and I managed to load that one into the div simply by eliminating the Jquery repository link, but this page doesn't want to know. 我还有另外四个链接可以调用页面,一个页面具有幻灯片放映,我设法通过消除Jquery存储库链接而将其加载到div中,但是该页面不想知道。

On the "shopping" page I have the following script, I've searched most of the web and also on here, without success, but nobody else's solutions have worked for me. 在“购物”页面上,我有以下脚本,我在网上和大部分地方进行了搜索,但均未成功,但是没有其他人的解决方案对我有用。 What am I doing wrong?: 我究竟做错了什么?:

<script type="text/javascript" src="./js/jquery.mousewheel.js"></script>
<script type="text/javascript" src="./js/jquery.jscrollpane.min.js"></script>
<link type="text/css" href="./css/jquery.jscrollpane.mod.css" rel="stylesheet" media="all" />


<script>

$(function()
{
$('.horizontal-only').jScrollPane(
{
    showArrows: true,
    arrowScrollOnHover: true,
    horizontalArrowPositions: 'split',
    hijackInternalLinks: false
}
);

  });

Ok... After some digging and trial and error, I've found the solution to my problem, hunting on the web and stack, I found something that worked and I thought for all those that are complete noobs, like me, in javascript and Jquery I'd post my findings. 好吧...经过一番挖掘和反复试验之后,我找到了解决问题的方法,在网络和堆栈上搜寻,发现了一些可行的方法,并且我认为所有像我这样完全菜鸟的人都在javascript中和Jquery我会发布我的发现。

Current call up on index page: 当前在索引页面上的调用:

  $(document).ready(function() {
  $("#shopping").click(function(event){
       $('#stage').hide();
      $('#stage').load('pages/shopping.html', {}, function() { $(this).fadeIn(800); });

I added the following to my index page (this is the page that is calling up the other pages) to the link of a specific page add: 我将以下内容添加到索引页面(这是调用其他页面的页面)到特定页面添加的链接:

 $.ajaxSetup({async:false});

then add the jScrollPane function after your call up eg: 然后在调用后添加jScrollPane函数,例如:

 $('#stage').jScrollPane(
{
    showArrows: true,
    arrowScrollOnHover: true,
    horizontalArrowPositions: 'split',
    hijackInternalLinks: false
}
);

So altogether it looks like this: 所以总共看起来像这样:

  $(document).ready(function() {
  $("#shopping").click(function(event){
       $('#stage').hide();
 //--added the async code here--//
       $.ajaxSetup({async:false});
      $('#stage').load('pages/shopping.html', {}, function() { $(this).fadeIn(800); });
 //--moved the jscrollPane from the page I was calling to the index page code here--//  
      $('#stage').jScrollPane(
{
    showArrows: true,
    arrowScrollOnHover: true,
    horizontalArrowPositions: 'split',
    hijackInternalLinks: false
}
);

This seems to be working for me at the moment, now I just need to re-edit some css and it's good to go. 目前,这似乎对我有用,现在我只需要重新编辑一些CSS,就可以了。

I've found another workaround: 我发现了另一个解决方法:

I've added the following code to the index.html: 我已将以下代码添加到index.html中:

$(function()
{
var api = $('.horizontal-only').jScrollPane(

{
    showArrows: true,
    arrowScrollOnHover: true,
    horizontalArrowPositions: 'split',
    hijackInternalLinks: false
}
).data('jsp');

$('#shopping').bind(
    'click',
    function()
    {
        api.getContentPane().load(
            'pages/shopping.html',
            function()
            {
                api.reinitialise();
            }
        );
        return false;
    }
);
});

I also made the jsp load in a separate div layer, as it was causing some styling conflicts and i can't determine where the issue is but this works. 我还在单独的div层中进行了jsp加载,因为这会导致一些样式冲突,并且我无法确定问题出在哪里,但是这可行。

What I also had to do is hide the new div layer from the other calls so basically: 我还必须做的是基本上从其他调用中隐藏新的div层:

$(#scroller).hide();

Thanks, I'm sure this isn't the best way, but as i've only had one reply on this issue, which was a question, think I've done rather well for a noob. 谢谢,我敢肯定这不是最好的方法,但是由于我对此问题只有一个答复,这是一个问题,以为我对新手来说做得很好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM