1
我創建了一個使用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();
}
});
記錄或提醒'$('#'+ 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