HTML Attribute rel Errors using fancyBox

后端 未结 6 966
青春惊慌失措
青春惊慌失措 2020-11-28 11:25

I\'m using fancyBox to create a gallery with the following code:




        
6条回答
  •  清歌不尽
    2020-11-28 12:02

    If you are still using fancybox v 1.x (which does not support data-fancybox-group) you can easily modify the script a bit.

    You only have to search and replace the "rel" attribute with something else, for instance "data-fancybox-gallery".

    When searching for the string "rel" you will find 4 elements. Be carefull only to change the last 3, because the first "rel" you find is part of position:relative.

    This is the part you have to change:

            var c = a(this).attr("rel") || "";
            if (!c || c == "" || c === "nofollow") {
                n.push(this)
            } else {
                n = a("a[rel=" + c + "], area[rel=" + c + "]");
                l = n.index(this)
            }
    

    Make it:

            var c = a(this).attr("data-fancybox-gallery") || "";
            if (!c || c == "" || c === "nofollow") {
                n.push(this)
            } else {
                n = a("a[data-fancybox-gallery=" + c + "], area[data-fancybox-gallery=" + c + "]");
                l = n.index(this)
            }
    

    And then your code should be:

        
        
        Thumb
    

提交回复
热议问题