2013-02-25 73 views
1

我試圖寫一個函數,從籃中轉移物品並將其推入購物車。 我目前面臨的問題是,儘管此代碼在FF和Chrome中正常工作,但它不會識別產品。IE問題與jquery和JS

很多預先感謝。

var modals_pool = {}; 

$('.deal_order_btn').live('click', function (e) { 
    e.preventDefault(); 

    deal = {}; 
    deal.id = $(this).attr('deal_id'); 
    deal.title = $(this).attr('deal_title'); 
    deal.items = []; 
    additional_total = 0; 
    $(this).parents('.deal_item_holder').find('table.deals_item_').each(function (index, ele) { 
     item = {}; 
     item.id = $(ele).attr('deal_item_id'); 
     item.name = $(ele).find('.deal_item_name a').text(); 
     if ($(ele).find('select.product').length) { 
      item.product = $(ele).find('select.product').val(); 
     } 
     if ($(ele).find('select.product').length === 0) { 
      item.product = $(ele).find('.deal_item_name a').attr('rel'); 
     } 
     if ($(ele).find('select.size').length) { 
      item.size = $(ele).find('select.size option:selected').text(); 
     } 
     if ($(ele).find('.static_size').length) { 
      item.size = $(ele).find('.static_size').text(); 
     } 


     deal_object = modals_pool[$(ele).attr('container_id').replace(/ /g, '_') + "_" + $(ele).find('.product').val()]; 

     //console.log(deal_object); 

     if ($(ele).find('select.product').length && deal_object) { 




      item.product_name = $(ele).find('select.product :selected').text(); 

      item.product_topping = deal_object.selected_topping_normal; 
      item.base = deal_object.default_base; 


      item.product_double_topping = deal_object.selected_topping_double; 


      item.product_total = deal_object.total; 
      additional_total += deal_object.total; 



     } 


     deal.items.push(item); 

    }); 



    deal.total = $(this).parents('li:first').find('span.customize_total_deal').text(); 
    deal.orginal = $(this).parents('li:first').find('span.customize_total_deal').attr('orginal_total'); 
    deal.addtional_topping_total = additional_total; 

    $.post(window.location.href, { 
     'action': '_saveUserDeal', 
      'deal_details': JSON.stringify(deal) 
    }, function (data) { 
     if (data.code) { 
      var date = new Date(); 
      var milseconds = date.getTime(); 
      $('.basket_box_holder').load(root + store_name + '/get_cart?' + milseconds); 
     } 
    }); 

}); 
+0

你使用的是什麼版本的jQuery? 'live()'方法從1.7開始被棄用,並在1.9 – Boaz 2013-02-25 13:56:14

+0

即時通過使用1.7 atm – ash 2013-02-25 13:59:32

+0

刪除,請隨時訪問此鏈接的實時版本:http://topspizza.co.uk/public/acton/deals/ – ash 2013-02-25 14:03:21

回答

1

你的腳本上線683斷開與錯誤:

Object doesn't support this action

這是因爲項目是在Internet Explorer中的保留關鍵字8及以下,嘗試重命名爲別的東西,或使用var關鍵字在當地申報項目。這可能會解決它:

var item = {}; 

乾杯。

+0

非常感謝, – ash 2013-02-25 18:07:12

+0

如果有幫助,你能接受這個答案嗎? :) – 2013-02-25 20:55:00