【问题标题】:Cannot call method createDocumentFragment of undefined无法调用未定义的方法 createDocumentFragment
【发布时间】:2013-09-25 08:16:58
【问题描述】:

我正在尝试实现magnific popup

我有以下链接<a class="simple-ajax-popup" href="/index.json">load json</a>

当我点击链接时,灯箱处于加载状态并抛出异常

Uncaught TypeError: Cannot call method 'createDocumentFragment' of undefined

我正在使用 rails 4 并且我有 jquery-fileupload 插件,但它正在工作。

【问题讨论】:

  • 您使用的是哪个版本的 magnific?
  • index.json 中有什么

标签: ruby-on-rails ruby-on-rails-3 jquery magnific-popup


【解决方案1】:

请阅读此Documentation: content type

您不能将 json 用作 html。您应该将 json 包装为 html。 你能做什么?

类似这样的:

$.magnificPopup.open({
  items: {
    src: '<div class="white-popup">Dynamically created popup</div>', // can be a HTML string, jQuery object, or CSS selector
    type: 'inline'
    callbacks: {
      open: function() {
       $.getJSON("/index.json").done(function( data) {
             data.each( function(index, value) {
               $("div.white-popup").append(value);
                       });
              })
       },
      close: function() {
           // Will fire when popup is closed
       }
});

希望对你有帮助。

【讨论】:

    猜你喜欢
    • 2018-05-06
    • 2021-04-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-08
    • 2015-06-27
    相关资源
    最近更新 更多