Jquery draggable不能在铬/ safari中工作
问题描述:
我创建了一个使用ajax调用来加载产品图像的页面。在index.php页面中,用于拖放,克隆的jquery代码无法工作,所以我将它移动到被调用以请求产品的页面,因为每个产品都拖放了为其创建的代码。Jquery draggable不能在铬/ safari中工作
在FF甚至IE中都能正常工作,但在Safari或Chrome中无法正常工作。下面是load_products.php中的jquery代码,它是在ajax调用加载产品时创建的。
http://tandyleatherfactory.net/
任何人有任何想法,为什么不会在Safari工作?
$(function() {$("#concho_4_2").draggable({
helper: 'clone',
cursor: 'pointer',
zIndex: '1001',
stop: function(event, ui)
{
offsetElement = $(ui.helper).offset();
offNewContainer = $('#belts').offset();
var dataId = $(ui.helper).attr('id');
ajaxRequest('http://tandyleatherfactory.net/includes/ahah/add_product.php', 'product=4', '#conchos');
var randomnumber = Math.floor(Math.random()*1000000);
var newId = 'concho_4_2_'+randomnumber;
$(ui.helper).clone(true).removeAttr('id').attr('id',newId).css("left", offsetElement.left-offNewContainer.left-10).css("top", offsetElement.top-offNewContainer.top-10).appendTo('#belts');
$('#'+newId).draggable();
}
});
答
找到了答案,加载的AJAX页面有标签包装的脚本标签,去掉标签,很快,在IE,FF,Safari浏览器,Chrome和Opera。
感谢您的建议。
记录或提醒'$('#'+ newId).draggable();'以确保脚本获得那么多。我发现在Safari中,克隆的元素没有获得“可拖动”类。 – user113716 2010-06-17 22:50:08
另外,不需要包装'ui.helper',只需使用'ui.helper.attr('id')'并且'ui.offset'被提供,不需要使用'ui.helper.offset ()' – Mottie 2010-06-18 00:49:54
警报没有产生任何东西,如果它正在工作,那么它们至少应该是可拖动的,但它们并非如此,因为我制作了你所建议的udpate。 我把可拖拽的代码复制到index.php页面,如果你选择1“conchos它是第一个concho。 不知道该怎么想 即使我mo – jbatson 2010-06-18 14:38:28