![](/img/trans.png)
[英]How can I add a close button to the Modal Box (Lightbox) Typo3 extension?
[英]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>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.