typo3 模态框的关闭按钮

Close button for typo3 modalbox

我找到了一个完美的 TYPO3 模态框指令 (http://www.andreas-hoffmeyer.de/blog/content-als-lightbox.html)。开头对于所有类型的内容元素都很好,但作者没有集成关闭按钮,向他寻求提示也没有成功。

我有一些打字稿

modal = PAGE
modal {
  typeNum = 123
  config {
    no_cache = 1
    disableAllHeaderCode = 1
    disablePrefixComment = 1
  }  
  10 < styles.content.get
  10 {
    select {    
      andWhere.data = GP:cid
      andWhere.intval = 1     
      andWhere.if.isTrue.data = GP:cid
      andWhere.wrap = uid=|  
    }
  }
}

还有一些 jquery

(function(window, document, $) {
    "use strict"
    $('.download').on('click', function(event) {
        event.preventDefault();
        // erstmal alle bisherigen Modalboxes entfernen
        $('.download').remove();
        var uri = [];       
        uri = $(this).attr('href').split('#');
        if (uri[1]) {   
            var cid = uri[1].replace(/[a-z]/gi, '');
            $.get(uri[0], {cid: cid, type: 123}, function(data, status) {
                appendToBody(data, status);
            });
            return true;
        }
        $.get(uri[0], {type: 123}, function(data, status) {
            appendToBody(data, status);
        });
    });
    function appendToBody(data, status) {
        if (status !== 'success') {
            throw Error('Error getting the content');
        }

        $('<div>', {
            id: 'modal',
            css: {
                (...)
            }
        }).html(data).appendTo('body');     
    }
})(window, document, jQuery);

现在我需要模态框内的关闭按钮,通过单击模态框外的某处关闭模态框会很棒。

我这样试过没有成功:

我在模态框中显示的页面上的 TYPO3 中创建了一个新的 HTML 内容元素并添加了

<p class="close">Close Window</p>

<script>
$( '.close' ).click(function() {
  $('.download').remove();
});
</script>

我找到了解决办法。这对我来说很好用:

<p class="close">Fenster schließen</p>

<script>
     (function(window, document, $) {
         $( '.close' ).click(function() {
              $('#modal').remove();
         });
    })(window, document, jQuery);
</script>