我试图更新与connectwith
连接一些可排序的div。我之前完成了一个表,更新查询工作,但是当涉及多个div时,它会变得棘手。问题是我在数据库中有一个名为div
的字段,它需要更新以及可排序对象正在放入的任何div,以及在该div内按特定顺序放置的字段。可排序的Portlet更新查询
编辑:SOOO,我怎么能创建多个div.id位置的排序更新查询?
结果我从刚刚更新一个DIV中的顺序代码工作进展,而是跨越多个div没有及时更新。另外,我并不确定找到div的最简单方法,我将内容移至内容并将其保存到数据库。
好了,所以这里是我到目前为止的代码只是一个专区内更新订单:
$(".heriyah").sortable({
handle : '.handle',
connectWith: ".heriyah",
revert: "invalid",
update : function() {
var order = $('.heriyah').sortable('serialize');
$("#info").load("admin/sortable.php?"+order);
}
});
而且PHP:
foreach ($_GET['listItem'] as $position => $item) :
$sql[] = "UPDATE `temp` SET `order` = $position WHERE `id` = $item";
endforeach;
print_r ($sql);
和HTML/PHP生成内容(使用大量的PHP和JQuery):
<script type="text/javascript">
(function() {
$('div.heriyah').each(function() {
$(this).html('<div class="add"><div id="add_button_container"><div id="add_button" class="edit_links">+ ADD NEW CONTENT</div></div></div><div class="clear"></div><div class="placeable" style="height:20px;background-color:#fff;"></div></div>');
var curID = $(this).attr('id');//get the id before you go into fallr
$('.add').click(function() {
$.fallr('show', {
content : '<iframe width="620" height="600" src="<? echo $URL ?>/manage_content.php?pageID=<? echo $pageID; ?>&div='+ curID +'"></iframe>',
width : 620 + 5, // 100 = for width padding
height : 600,
closeKey : true,
closeOverlay : true,
buttons : {}
});
});
});
})();
<?
include_once('system/js/dbc.php');
$pageID = $_REQUEST['pageID'];
$getdiv2 = mysql_query("SELECT * FROM temp WHERE pageID = '$pageID' ORDER BY `order` ASC");
while ($row = mysql_fetch_assoc($getdiv2))
{
echo "$('#{$row['div']}.heriyah').append('<div class=sortable id=listItem_{$row['id']}><div id=heriyah_content class=sortable_header>{$row['title']}<br>{$row['maintext']}<div id=heriyah_handle class=handle></div><a onClick=edit_{$row['id']}();return false><div id=heriyah_content_hover></div></a></div></div>');\n";
}
?>
</script>
<script>
$(".heriyah").sortable({
handle : '.handle',
connectWith: ".heriyah",
revert: "invalid",
update : function() {
var order = $('.heriyah').sortable('serialize');
$("#info").load("admin/sortable.php?"+order);
}
});
</script>
<div id="info"></div>
我需要澄清的人什么吗? – drummer392
是的。请将实际问题放入您的帖子中。 – Tadeck
同意Tadeck。你通过使用你的代码得到的结果是什么以及需要哪种结果? – arma