Showing
2 changed files
with
28 additions
and
38 deletions
@@ -5,8 +5,8 @@ | @@ -5,8 +5,8 @@ | ||
5 | * @date: 2015/10/21 | 5 | * @date: 2015/10/21 |
6 | */ | 6 | */ |
7 | 7 | ||
8 | -var $ = require('jquery'); | ||
9 | -var Handlebars = require('yoho.handlebars'); | 8 | +var $ = require('jquery'), |
9 | + Handlebars = require('yoho.handlebars'); | ||
10 | 10 | ||
11 | var $page = $('.yoho-page'); | 11 | var $page = $('.yoho-page'); |
12 | 12 | ||
@@ -37,7 +37,7 @@ function remove() { | @@ -37,7 +37,7 @@ function remove() { | ||
37 | $('.chose-panel').remove(); | 37 | $('.chose-panel').remove(); |
38 | } | 38 | } |
39 | 39 | ||
40 | -$('.yoho-page').delegate('.chose-panel', 'tap', function(e) { | 40 | +$('.yoho-page').on('touchstart', '.chose-panel', function(e) { |
41 | var $cur = $(e.target); | 41 | var $cur = $(e.target); |
42 | 42 | ||
43 | if ($cur.closest('.main').length > 0) { | 43 | if ($cur.closest('.main').length > 0) { |
@@ -46,10 +46,10 @@ $('.yoho-page').delegate('.chose-panel', 'tap', function(e) { | @@ -46,10 +46,10 @@ $('.yoho-page').delegate('.chose-panel', 'tap', function(e) { | ||
46 | 46 | ||
47 | //点击蒙版消失 | 47 | //点击蒙版消失 |
48 | remove(); | 48 | remove(); |
49 | -}).delegate('#chose-btn-sure', 'tap', function() { | 49 | +}).on('touchstart', '#chose-btn-sure', function() { |
50 | 50 | ||
51 | //确定 | 51 | //确定 |
52 | -}).delegate('.block', 'tap', function() { | 52 | +}).on('touchstart', '.block', function() { |
53 | 53 | ||
54 | //尺寸颜色点选 | 54 | //尺寸颜色点选 |
55 | var $this = $(this); | 55 | var $this = $(this); |
@@ -60,7 +60,7 @@ $('.yoho-page').delegate('.chose-panel', 'tap', function(e) { | @@ -60,7 +60,7 @@ $('.yoho-page').delegate('.chose-panel', 'tap', function(e) { | ||
60 | 60 | ||
61 | $this.siblings('.chosed').removeClass('chosed'); | 61 | $this.siblings('.chosed').removeClass('chosed'); |
62 | $this.addClass('chosed'); | 62 | $this.addClass('chosed'); |
63 | -}).delegate('.btn-minus', 'tap', function() { | 63 | +}).on('touchstart', '.btn-minus', function() { |
64 | var num = +$num.val(); | 64 | var num = +$num.val(); |
65 | 65 | ||
66 | if (num === 1) { | 66 | if (num === 1) { |
@@ -68,7 +68,7 @@ $('.yoho-page').delegate('.chose-panel', 'tap', function(e) { | @@ -68,7 +68,7 @@ $('.yoho-page').delegate('.chose-panel', 'tap', function(e) { | ||
68 | } | 68 | } |
69 | 69 | ||
70 | $num.val(num - 1); | 70 | $num.val(num - 1); |
71 | -}).delegate('.btn-plus', 'tap', function() { | 71 | +}).on('touchstart', '.btn-plus', function() { |
72 | var num = +$num.val(); | 72 | var num = +$num.val(); |
73 | 73 | ||
74 | //TODO:库存数验证 | 74 | //TODO:库存数验证 |
@@ -10,21 +10,14 @@ var $ = require('jquery'), | @@ -10,21 +10,14 @@ var $ = require('jquery'), | ||
10 | 10 | ||
11 | var chosePanel = require('./chose-panel'); | 11 | var chosePanel = require('./chose-panel'); |
12 | 12 | ||
13 | +//删除面板显示后任何点击行为都将触发隐藏面板 | ||
13 | function docTouchEvt(e) { | 14 | function docTouchEvt(e) { |
14 | - var $tar = $(e.target); | 15 | + $('.opt-panel:not(.hide)').addClass('hide'); |
15 | 16 | ||
16 | - if ($tar.closest('.opt-panel').length === 0) { | ||
17 | - $('.opt-panel:not(.hide)').addClass('hide'); | ||
18 | - | ||
19 | - // | ||
20 | - $(document).unbind('tap', docTouchEvt); | ||
21 | - } | 17 | + // |
18 | + $(document).off('touchstart', docTouchEvt); | ||
22 | } | 19 | } |
23 | 20 | ||
24 | -// function unbindDocTouchEvt(e) { | ||
25 | -// $(document).unbind('tap', docTouchEvt); | ||
26 | -// } | ||
27 | - | ||
28 | ellipsis.init(); | 21 | ellipsis.init(); |
29 | 22 | ||
30 | lazyLoad($('.lazy')); | 23 | lazyLoad($('.lazy')); |
@@ -32,7 +25,7 @@ lazyLoad($('.lazy')); | @@ -32,7 +25,7 @@ lazyLoad($('.lazy')); | ||
32 | $('.name')[0].mlellipsis(2); | 25 | $('.name')[0].mlellipsis(2); |
33 | 26 | ||
34 | //TIP:事件委托在.cart-goods,商品列表的容器统一需要有.cart-goods | 27 | //TIP:事件委托在.cart-goods,商品列表的容器统一需要有.cart-goods |
35 | -$('.cart-goods').delegate('.checkbox', 'tap', function() { | 28 | +$('.cart-goods').on('touchstart', '.checkbox', function() { |
36 | var $this = $(this); | 29 | var $this = $(this); |
37 | 30 | ||
38 | if ($this.hasClass('icon-cb-checked')) { | 31 | if ($this.hasClass('icon-cb-checked')) { |
@@ -40,7 +33,7 @@ $('.cart-goods').delegate('.checkbox', 'tap', function() { | @@ -40,7 +33,7 @@ $('.cart-goods').delegate('.checkbox', 'tap', function() { | ||
40 | } else { | 33 | } else { |
41 | $this.removeClass('icon-checkbox').addClass('icon-cb-checked'); | 34 | $this.removeClass('icon-checkbox').addClass('icon-cb-checked'); |
42 | } | 35 | } |
43 | -}).delegate('.icon-edit', 'tap', function() { | 36 | +}).on('touchstart', '.icon-edit', function() { |
44 | var id = $(this).closest('.shopping-cart-good').data('id'); | 37 | var id = $(this).closest('.shopping-cart-good').data('id'); |
45 | 38 | ||
46 | $.ajax({ | 39 | $.ajax({ |
@@ -55,36 +48,33 @@ $('.cart-goods').delegate('.checkbox', 'tap', function() { | @@ -55,36 +48,33 @@ $('.cart-goods').delegate('.checkbox', 'tap', function() { | ||
55 | } | 48 | } |
56 | } | 49 | } |
57 | }); | 50 | }); |
58 | -}).delegate('.icon-del', 'tap', function(e) { | 51 | +}).on('touchstart', '.icon-del', function(e) { |
59 | e.stopPropagation(); | 52 | e.stopPropagation(); |
60 | 53 | ||
61 | $(this).closest('.shopping-cart-good').children('.opt-panel').removeClass('hide'); | 54 | $(this).closest('.shopping-cart-good').children('.opt-panel').removeClass('hide'); |
62 | 55 | ||
63 | - $(document).bind('tap', docTouchEvt); | ||
64 | -}).delegate('.opt-panel', 'tap', function() { | 56 | + $(document).on('touchstart', docTouchEvt); |
57 | +}).on('touchstart', '.opt-panel', function() { | ||
65 | var $this = $(this), | 58 | var $this = $(this), |
66 | - id = $this.closest('.shopping-cart-good').data('id'); | 59 | + id = $this.closest('.shopping-cart-good').data('id'), |
60 | + url; | ||
67 | 61 | ||
68 | if ($this.closest('.put-in-favorite')) { | 62 | if ($this.closest('.put-in-favorite')) { |
69 | 63 | ||
70 | //移入收藏夹 | 64 | //移入收藏夹 |
71 | - $.ajax({ | ||
72 | - type: 'POST', | ||
73 | - url: '/shoppingCart/col', | ||
74 | - data: { | ||
75 | - id: id | ||
76 | - } | ||
77 | - }); | 65 | + url = '/shoppingCart/col'; |
78 | } else { | 66 | } else { |
79 | 67 | ||
80 | //删除 | 68 | //删除 |
81 | - $.ajax({ | ||
82 | - type: 'POST', | ||
83 | - url: '/shoppingCart/del', | ||
84 | - data: { | ||
85 | - id: id | ||
86 | - } | ||
87 | - }); | 69 | + url = '/shoppingCart/del'; |
88 | } | 70 | } |
71 | + | ||
72 | + $.ajax({ | ||
73 | + type: 'POST', | ||
74 | + url: url, | ||
75 | + data: { | ||
76 | + id: id | ||
77 | + } | ||
78 | + }); | ||
89 | }); | 79 | }); |
90 | 80 |
-
Please register or login to post a comment