Code Monkey home page Code Monkey logo

Comments (2)

catouse avatar catouse commented on August 17, 2024

Lightbox 只会自动初始化页面加载时出现在页面上的 [data-toggle="lightbox"] 元素作为触发元素。如果要为动态插入的内容启用 Lightbox 有两种方式:

  1. 在动态内容插入到页面后,选中动态插入的内容并调用 lightbox() 方法。
$('#newContents [data-toggle="lightbox"]').lightbox();
  1. 检测所有 [data-toggle="lightbox"] 元素上的点击事件,如果没有初始化则进行初始化并再次触发点击事件。
$(document).on('click', '[data-toggle="lightbox"]', function() {
    var $this = $(this);
    if(!$this.data('zui.lightbox')) {
        $this.lightbox().trigger('click');
    }
});

from zui.

blessyezi avatar blessyezi commented on August 17, 2024

非常感谢!搞定啦:+1:
由于vue是双向绑定,用第一种方法可能还需要加一个延时,所以使用了第二种方法.

from zui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.