取list中的值时候总是取到第一个值

1.取list中的值时候总是取到第一个值

<div class="brands pro_hd my_co">
<#assign collectTag = newTag("collectTag") />
<#assign collect = collectTag()!'' />
<#assign collectList = collect.result />
        <div class="bd">
    <#if collectList?exists && (collectList?size > 0) >
<ul class="">
<#list collectList as favorite>
<li>
<a href="javascript:void(0);"></a>
                  <div class="goods-img">
<a href="javascript:;" class="tap" data-href="${ctx}/goods-${favorite.goods_id}.html"><@image src="${favorite.thumbnail!''}"/></a>
                   </div>
<div class="li_ri">
                       <h3><span class="tap" data-href=""><@substring title="${favorite.name!''}" length=74 dot='...' /></span></h3>
                       <span class="sm">${favorite.goods_model_id!''}</span>
                       <span class="pr">${favorite.sale_price?string.currency}起</span>
                       <span class="kc">库存 :${favorite.own_store!'0'}</span>
                       <#assign own_store = favorite.own_store!''/>
                       <#if (own_store > 0 ) >
                        <i class="huo youhuo f26">现在有货</i>
                       <#else/>
                        <i class="huo youhuo f26">现在无货</i>
                       </#if>
                       <div class="goods-detai-buttons del">
                             <span class="btn-item delete" data-id="${favorite.favorite_id}"><img src="${ctx}${themes_path}/images2.0/zvcxxc03-05.jpg"></span>
                       </div>
                    </div>
                 </a>
              </li>
            </#list>
            </ul>
        </div>
    </div>


2.js取值

$(function(){
var deviceWidth = document.documentElement.clientWidth;
if(deviceWidth > 750) deviceWidth = 750;
document.documentElement.style.fontSize = deviceWidth / 7.5 + 'px';
var module = new Module();
$('.delete').click(function () {


var _this = $(this),

// 防止取到总是第一个值
_id   = _this.attr('data-id');
module.loading.open();
module.layerConfirm({
content: '删除收藏该商品吗?',
yes: function () {
_ajax();
}
})


        function _ajax() {
            $.ajax({
                url : ctx + '/api/shop/collect/cancel-collect.do',
                data: {favorite_id: _id},
                type: 'POST',
                success: function (res) {
                    if(res.result == 1){
                        module.message.success('删除成功!', function () {
                            location.replace(ctx + '/member/my-collect.html?type=goods');
                        });
                    }else {
                        module.loading.close();
                        module.message.error(res.message);
                    }
                },
                error: function () {
                    module.loading.close();
                    module.message.error('出现错误,请重试!');
                }
            })
        }


        return false
    })
});




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值