我有一個多列(兩列div),從循環中檢索一些來自MySQL的信息。 (用戶名,小時,留言)。jQuery/AJAX刪除後留下白色空白空格里面多列div
+---------------------------+ +---------------------------+
| StackOverflow User | | StackOverflow User2 |
| 11:31 AM X | | 11:37 AM X |
| | | |
| Stack Overflow is a | | Tags make it easy to find |
| question and answer site | | interesting questions. |
| for professional and | | All questions are tagged |
| enthusiast programmers. | | with their subject areas. |
| It's built and run by you | | Each can have up to 5 |
| as part of the Stack | | tags, since a question |
| Exchange network of Q&A | | might be related to |
| sites. | | several subjects. |
| | | Click any tag to see a |
+---------------------------+ | list of questions with |
| that tag, or go to the |
+---------------------------+ | tag list to browse for |
| StackOverflow User2 | | topics that interest you. |
| 11:56 AM X | +---------------------------+
| |
| This post is not to | +---------------------------+
| explain anything but just | | Stackoverflow User9 |
| to show how the divs are | | 2 days ago X |
| are the current moment | | |
| and to describe their | | Whoever sees this post |
| issue that I'm unable | | I appreciate for the help |
| to know what is causing | | And who ever looks for |
| if it's jQuery type of | | help in the same subject |
| mansory or the Ajax. | | I hope you find what you |
+---------------------------+ | are looking for as it can |
| be tough to find something|
| that you're both needing |
| help with.. sometimes:) |
+---------------------------+
我現在的問題是,如果我按一下X按鈕刪除後,它不會完全刪除它,因爲我已經成立,但刪除後離開 高度盒子而不是底部框(被刪除的框下面的框)佔據空間並移動到其位置。問題如下:
單擊左側第一個帖子的刪除按鈕後。
+---------------------------+
| StackOverflow User2 |
| 11:37 AM X |
| |
| Tags make it easy to find |
| interesting questions. |
| All questions are tagged |
| with their subject areas. |
| Each can have up to 5 |
| tags, since a question |
| might be related to |
| several subjects. |
| Click any tag to see a |
| list of questions with |
| that tag, or go to the |
+---------------------------+ | tag list to browse for |
| StackOverflow User2 | | topics that interest you. |
| 11:56 AM X | +---------------------------+
| |
| This post is not to | +---------------------------+
| explain anything but just | | Stackoverflow User9 |
| to show how the divs are | | 2 days ago X |
| are the current moment | | |
| and to describe their | | Whoever sees this post |
| issue that I'm unable | | I appreciate for the help |
| to know what is causing | | And who ever looks for |
| if it's jQuery type of | | help in the same subject |
| mansory or the Ajax. | | I hope you find what you |
+---------------------------+ | are looking for as it can |
| be tough to find something|
| that you're both needing |
| help with.. sometimes:) |
+---------------------------+
讓元素的高度被刪除,而不是第二個帖子的高度降低,並將其放置。 我相信目前的問題與jQuery一樣,它是如何檢查元素的高度和自動調整,但我不確定,如果我刪除另一個 正確地上升。
這是我目前使用的代碼。
jQuery的多柱高度與它左右列調整的CSS>
$(document).ready(function()
{
var left_column_height = 0;
var right_column_height = 0;
var items = $('.item');
for (var i = 0; i < items.length; i++)
{
if (left_column_height > right_column_height)
{
right_column_height+= items.eq(i).addClass('right').outerHeight(true);
} else {
left_column_height+= items.eq(i).outerHeight(true);
}
}
});
.wrap { width: 100% }
.wrap .item { width: 49%;float: left;clear: left; }
.wrap .item.right { float: right;clear: right; }
阿賈克斯/ jQuery的刪除帖子。 (可能不需要那麼我就做什麼,以顯示它是如何)
$(document).ready(function()
{
$('.postdelete').on("click",function()
{
var iD = $(this).attr("id");
var dataString = 'post_iD='+ iD;
if(confirm("Sure you want to delete this update?"))
{
$.ajax(
{
type: "POST",
url: "load_ajax/delete_message_ajax.php", // just passes a isset $_POST.
data: dataString,
cache: false,
success: function(html)
{
$("#stbody"+iD).slideUp()("slow",function(){ $("#stbody"+iD).remove().slideUp("slow"); });
}
});
}
return false;
});
});
的Html普通股利
<div class="wrap" id="php get id">
<div class="item">
<div class="box">
<a>StackOverflow User</a>
<a>11:31 AM</a>
<a>MESSAGE</a>
</div>
</div>
</div>
從什麼我知道,我只是「數字」,這似乎更加明顯該問題肯定來自jQuery多列列表或AJAX帖子。 我明白那裏有Mansonry和其他一些腳本,但是我會選擇較小的代碼來完成同樣的事情,再加上我只會在這裏使用它,所以我寧願堅持一個小的一段代碼比移動到更大的一個並導致服務器壓力。
UPDATE 2:經過測試,我相信問題出在jQuery上,因爲它只讀取.right而不是.left,所以它只刪除空白空間,如果我刪除了正確的。
我覺得你有一個額外的'()'第一'slideUp'在'$後(「#stbody」+ iD).slideUp()(「slow」,function(){$(「#stbody」+ iD).remove()。slideUp(「slow」);});'。嘗試刪除 - 「$(」#stbody「+ iD).slideUp(」slow「,function(){$(」#stbody「+ iD).remove()。slideUp(」slow「);});' – Sean
你是對的,我確實有一個額外的(),但它仍然沒有改變這個問題! – iBrazilian