arttemplate初次使用

   <table width="100%" border="0" cellspacing="0" cellpadding="0" id="mCSB_1_container">
                            <tr>
                                <td height="49" colspan="2" align="center">
                                    <img src="images/2/top2.png" width="40%" /></td>
                            </tr>
                            <tr bgcolor="#171E2E">
                                <td width="65%" height="36" align="center">名称</td>
                                <td align="center">所需奖券</td>
                            </tr>

                        </table>
                    </td>
                </tr>
            </table>

  <!--模板--> <script id="container" type="text/html"> {{each list as value i}} {{if i%2==0}} <tr> <td height="36" align="left" style="padding: 0 0 0 12px"> <a href="javascript:void(0);" onclick='js_method({{value.SalePrice}},{{value.Id}});return false;'> <img src="images/2/B-{{i+1}}.png" height="70%" border="0" align="absmiddle" /><span class="zs">{{value.ProductName}}</span></a></td> <td align="center" class="zaa">{{value.SalePrice}}</td> </tr> {{else}} <tr bgcolor="#171E2E"> <td height="36" align="left" style="padding: 0 0 0 12px"> <a href="javascript:void(0);" onclick='js_method({{value.SalePrice}},{{value.Id}});return false;'> <img src="images/2/B-{{i+1}}.png" height="70%" border="0" align="absmiddle" /><span class="zs">{{value.ProductName}}</span></a></td> <td align="center" class="zaa">{{value.SalePrice}}</td> </tr> {{/if}} {{/each}} </script> </body> </html> <script> var userid='<%=userid%>'; var sign='<%=sign%>'; function js_method(needm, Id) { $.ajax({ type: "post", url: "/58867Wap/Handlers/ProductListHandler.ashx", dataType: 'text', data: { 'userid': userid, 'typeid': -1, 'action': 'ALL' }, success: function (data) { var dataObj = $.parseJSON(data); var result = dataObj; if (result[1][7] < needm) { alert('对不起,您的奖券不足。', function () { parent.window.location = "list2.aspx?userid=" + userid + "&sign=" + sign + "" }); return; } else { parent.window.location = "listView.aspx?Id=" + Id + "&userid=" + userid + "&sign=" + sign + ""; } } }); }     <!--获取列表--> $.ajax({ type: "post", url: "/58867Wap/Handlers/ProductListHandler.ashx", dataType: 'json', data: { 'userid': <%=userid%>, 'typeid': -1, 'action': 'ALL' }, success: function (data) { var tempData =[]; tempData.list=data; var html = template('container', tempData); $('#mCSB_1_container').append(html); } }); </script>

 

posted @ 2016-05-27 18:12  唔愛吃蘋果  阅读(313)  评论(0编辑  收藏  举报