javascript - Bootstrap 轮播 - JavaScript 不适用(DNN)

标签 javascript twitter-bootstrap twitter-bootstrap-3 carousel dotnetnuke

首先我要说的是我对 JavaScript 几乎一无所知。

我有一个 Bootstrap (3) 轮播,其中包含不同数量的图像和文本。当轮播动画时,轮播下方的所有内容都会跳跃,因为轮播会根据内容的高度调整其高度。

我已关注http://ryanringler.com/blog/2014/08/24/fixed-height-carousel-for-twitter-bootstrap它旨在计算轮播内内容的最大高度,并应用于每张幻灯片 - 防止轮播下方的页面内容跳转。这几乎解决了问题,但还没有完全解决。

看来 javascript 仅在我调整浏览器窗口大小后才适用。由于基本上不了解 JS 的工作原理,我希望有一个简单的解决方案,有人可以帮助我?我将永远感激不已!

我在 DNN 中的页面设置 > 高级设置的页面标题标签部分加载了以下内容。

window.onload = function() {
  carouselNormalization();
}

我在页面上的 html 模块的脚本标记中加载了以下内容:

function carouselNormalization() {
  var items   = $('#carousel-reviews .item'),              // grab all the slides
      heights = [],                                   // array to store heights
      tallest;                                        // tallest slide

  if (items.length) {
    function normalizeHeights() {
      items.each(function() {
        heights.push($(this).height());               // add each slide's height
      });                                             // to the array

      tallest = Math.max.apply(null, heights);        // find the largest height

      items.each(function() {
        $(this).css('min-height', tallest + 'px');    // set each slide's minimum
      });                                             // height to the largest
    };

    normalizeHeights();

    $(window).on('resize orientationchange', function() {
      tallest = 0, heights.length = 0;               // reset the variables

      items.each(function() {
        $(this).css('min-height', '0');              // reset each slide's height
      });

      normalizeHeights();                            // run it again
    });
  }
}

这是页面:http://mystate.com.au/about-us/contact-us/locations/launceston-branch

我还注意到,有时如果我在页面加载后立即按下滚动按钮,JS 确实会应用,但如果我等待几秒钟,似乎不会应用。

感谢您提前提供的任何帮助!

最佳答案

Chrome 控制台显示:carouFredSel: No element found for "#carousel_2item"也适用于#carousel_4item 。你可能应该先解决这个问题。

还有 ID carousel-id您的网站上不存在。您可能需要将其替换为实际元素的 ID。 (尝试carousel-reviews)

关于javascript - Bootstrap 轮播 - JavaScript 不适用(DNN),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44582922/

相关文章:

javascript - 使用 Coffeescript 读取本地文件

javascript - Node Express 服务器 : How to serve HTML file properly (scripts and css included) ?(csp、相对路径和类似的东西)

css - 如何在 Bootstrap 中减小 html 视频播放器的大小

php - 我希望搜索结果显示在列中,但只有文本显示

javascript - 如何实现复选框的属性来跟踪表中每一行的更改,而不使用 Grid 对象或 jQuery.Data(Input)?

javascript - 如何重新提交 HTML 表单

javascript - 禁用提交按钮,直到至少选中一个复选框

javascript - AngularJS Bootstrap 崩溃了

javascript - 为 Bootstrap Carousel 添加不同的效果

css - 图像通过桌面上的引导轮播旋转到水平