久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

jquery dotdot 插件(添加省略號)不適用于 Bootstrap 輪

jquery dotdotdot plugin (adds ellipsis) not working with Bootstrap carousel(jquery dotdot 插件(添加省略號)不適用于 Bootstrap 輪播)
本文介紹了jquery dotdot 插件(添加省略號)不適用于 Bootstrap 輪播的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我正在為我的 Rails 4 應用程序使用 Bootstrap 3 輪播.為了截斷輪播中較長的字幕,我使用了 jquery dotdotdot 插件,該插件還在末尾附加了...".雖然該插件適用于輪播中的第一張圖片,但不適用于后續圖片.

I'm using the Bootstrap 3 carousel for my Rails 4 application. To truncate longer captions in the carousel, I'm using the jquery dotdotdot plugin which also appends "..." at the end. While the plugin works for the first image in the carousel, it doesn't work for subsequent images.

這是 jsfiddle:http://jsfiddle.net/michaelvli/GD3JH/9/

Here's the jsfiddle: http://jsfiddle.net/michaelvli/GD3JH/9/

為什么 dotdotdot 沒有在輪播的所有字幕上執行?我嘗試使用輪播事件處理程序在每次輪播滑動時執行插件,但此解決方案不適合,因為在 dotdotdot 有機會執行之前,用戶會在短時間內看到完整的標題:

Why is dotdotdot not executing on all captions of the carousel? I've tried using a carousel event handler to execute the plugin every time the carousel slides but this solution isn't suitable as the user will see the full caption for a brief moment before dotdotdot has had a chance to execute:

$('.carousel').on('slide.bs.carousel', function () {
    $('.dotdotdot').dotdotdot({});
});

或者,如果有人可以推薦另一種解決方案,即截斷多行字幕,同時在末尾附加...",那也很棒.

Alternatively, if somebody can recommend another solution that truncates multi-line captions while appending a "..." to the end, that would be great too.

推薦答案

問題在于,由于它沒有顯示所有項目,因此沒有在每個項目的末尾應用 ...,那些隱藏沒有激活.為了解決這個問題,我們將所有項目都設置為 active item 類,以便顯示它們,然后將除第一張幻燈片(或元素 0)之外的所有項目切換到 item.再次隱藏它們.所以我們可以添加這個:

The problem is that since it is not showing all items it's not applying the ... at the end of each, the ones hidden are not activating. To solve this we have all items to be the class active item so they are shown then switch all but the first slide (or element 0) to item. To hide them again. So we can add this:

$( ".active.item" ).each(function( index ) {
    if(index != 0){
        $(this).removeClass('active');
    }
});

現在我們所有的項目都受到點點的影響.

Now we have all the items affected properly by the dotdotdot.

小提琴這里

這篇關于jquery dotdot 插件(添加省略號)不適用于 Bootstrap 輪播的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

jQuery/JavaScript Library for avatar creation?(用于創建頭像的 jQuery/JavaScript 庫?)
How to do following mask input problem?(如何做以下掩碼輸入問題?)
Issues Setting Value/Label Using DropKick Javascript(使用 DropKick Javascript 設置值/標簽的問題)
how to unit-test private methods in jquery plugins?(如何對 jquery 插件中的私有方法進行單元測試?)
stellar.js - configuring offsets / aligning elements for a vertical scrolling website?(stellar.js - 為垂直滾動網站配置偏移量/對齊元素?)
jQuery masked input plugin. select all content when textbox receives focus(jQuery 屏蔽輸入插件.當文本框獲得焦點時選擇所有內容)
主站蜘蛛池模板: 懂色av一区二区三区 | 在线观看亚洲一区 | 一级片黄色片 | 依人在线| 亚洲视频在线看 | 狠狠婷婷| 三级福利视频 | 成人午夜网站 | av手机在线看 | 免费三片在线播放 | 久久精品国产成人av | 日韩一二三 | 日日干天天干 | 国内精品一区二区三区 | 一级免费毛片 | 亚洲国产精品suv | 综合色在线| 久久精品一区二区三区四区 | 97精品国产97久久久久久免费 | 超碰人人干 | 亚洲成人av在线播放 | 国产二区精品 | 午夜激情网 | 中文字幕在线观看不卡 | 久久这里只有精品6 | 亚洲欧美精品 | 四虎影| 国产乱码精品一区二区三区忘忧草 | 亚洲精品一区二区三区在线 | 韩日一级片 | 国产福利一区二区三区 | 精品国产一区二区三区久久久蜜月 | 成人特级毛片 | 色婷婷亚洲 | 国产在线日韩 | 91福利区| 亚洲91精品 | 97超碰人人| 视频爱爱免费视频爱爱太爽 | 精品免费国产一区二区三区四区 | 亚洲综合伊人 |