无法调用undefined方法createDocumentFragment

时间:2013-09-20 03:28:58

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

我正在尝试实施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插件,但它正在运行。

1 个答案:

答案 0 :(得分:2)

请阅读此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
       }
});

我希望它有所帮助。