Add dynamic html to fancy box

廉价感情. 提交于 2019-12-11 03:36:51

问题


Been using FancyBox to display a swf player. What I would like to do is have an if statement that, when false adds the flash vars to 'swf': {...}, which I have working. And when true displays some inline markup.

if (true) {
    $.fancybox({
        'type': inline
        //can I ref markup here???
    });
} else {
    $.fancybox({
        'href' : somepath,
        'type': 'swf',
        'swf': {..}
    });
}

Would someone be able to advise on how I can either reference the markup using the approach above. Or if I can even add dynamic html here, which would be a nicer approach.

Thanks in advance

Eddie


回答1:


Solved this.

I needed to use the key content, which forces FancyBox to load the html content:

if(true){
  var content = $('#someHtml').html();
  $.fancybox({
      'content': content,
      'padding' : 20
  });
}else{...}


来源:https://stackoverflow.com/questions/3877282/add-dynamic-html-to-fancy-box

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!