问题描述
代码如下:<%@PageLanguage="C#"AutoEventWireup="true"CodeBehind="cart.aspx.cs"Inherits="EmptyProjectNet20.cart"%><!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><htmlxmlns="http://www.w3.org/1999/xhtml"><headrunat="server"><title></title><linkhref="~/res/css/main.css"rel="stylesheet"type="text/css"/><style>body.x-body{padding:0;}.totalpanel.x-panel-body{border-top-width:0!important;}</style></head><body><formid="form1"runat="server"><x:PageManagerID="PageManager1"AutoSizePanelID="Panel2"runat="server"/><x:PanelID="Panel2"runat="server"ShowBorder="false"Layout="VBox"BoxConfigAlign="Stretch"BoxConfigPosition="Start"BodyPadding="5px"BoxConfigChildMargin="0500"ShowHeader="false"><Items><x:GridID="Grid1"ShowBorder="true"BoxFlex="1"ShowHeader="true"Title="购物车"EnableCollapse="true"runat="server"EnableCheckBoxSelect="true"CheckBoxSelectOnly="true"DataKeyNames="Id,Code,Name"EnableTextSelection="true"><Columns><x:BoundFieldWidth="120px"DataField="Code"DataFormatString="{0}"HeaderText="商品代码"/><x:BoundFieldDataField="Name"ExpandUnusedSpace="true"DataFormatString="{0}"HeaderText="商品名称"/><x:BoundFieldWidth="120px"DataField="Price"HeaderText="商品单价"DataFormatString="¥{0:F}"/><x:TemplateFieldHeaderText="数量"Width="120px"><ItemTemplate><inputid="Hidden1"type="hidden"class="price"runat="server"value='<%#Eval("Price")%>'/><asp:TextBoxrunat="server"Width="98%"ID="tbxNumber"CssClass="number"TabIndex='<%#Container.DataItemIndex+10%>'Text='<%#Eval("Number")%>'></asp:TextBox></ItemTemplate></x:TemplateField><x:TemplateFieldHeaderText="小计"Width="120px"><ItemTemplate><asp:LabelID="Label1"runat="server"CssClass="xiaoji"Text='<%#"¥"+GetXiaoji(Eval("Price"),Eval("Number"))%>'></asp:Label></ItemTemplate></x:TemplateField></Columns></x:Grid><x:ContentPanelrunat="server"CssClass="totalpanel"ShowBorder="true"ShowHeader="false"><divstyle="text-align:right;margin:10px;"><divstyle="margin-bottom:10px;"><inputid="TOTAL_NUMBER"name="TOTAL_NUMBER"/><spanid="totalNumber"style="color:red;"></span>件商品</div><divstyle="margin-bottom:10px;"><inputtype="hidden"id="TOTAL_PRICE"name="TOTAL_PRICE"/>总计:<spanid="totalPrice"style="color:red;font-size:1.5em;font-weight:bold;"></span></div><div><x:Buttonrunat="server"Text="去结算"Enabled="true"Size="Large"ID="btnGotoPay"OnClick="btnGotoPay_Click"></x:Button></div>alert("运行到了这里!脚本没有运行呀");</div></x:ContentPanel></Items></x:Panel></form><scriptsrc="~/res/js/jquery.min.js"type="text/javascript"></script><scripttype="text/javascript">vargridClientID='<%=Grid1.ClientID%>';varbtnGotoPayClientID='<%=btnGotoPay.ClientID%>';varnumberSelector='.f-grid-tplinput.number';varpriceSelector='.f-grid-tplinput.price';functiongetRowNumber(row){returnparseInt(row.find(numberSelector).val(),10);}functiongetRowPrice(row){returnparseFloat(row.find(priceSelector).val());}functionupdateTotal(){vargrid=F(gridClientID);varselection=grid.getSelectionModel().getSelection();varstore=grid.getStore();vartotal=0;$.each(selection,function(index,item){varrowIndex=store.indexOf(item);varrow=$(grid.body.el.dom).find('.x-grid-row').eq(rowIndex);total+=getRowNumber(row)*getRowPrice(row);});$('#totalNumber').text(selection.length);$('#totalPrice').text("¥"+total.toFixed(2));$('#TOTAL_NUMBER').val(selection.length);$('#TOTAL_PRICE').val(total.toFixed(2));vargotoPayBtn=F(btnGotoPayClientID);if(total===0){gotoPayBtn.disable();}else{gotoPayBtn.enable();}}functionregisterNumberChangeEvents(){vargrid=F(gridClientID);//数量改变事件//http://stackoverflow.com/questions/17384218/jquery-input-event$(grid.el.dom).find(numberSelector).on('inputpropertychange',function(evt){var$this=$(this);varrow=$this.parents('.x-grid-row');varnumber=getRowNumber(row);varprice=getRowPrice(row);varresultNode=row.find('.f-grid-tplspan.xiaoji');resultNode.text("¥"+(number*price).toFixed(2));updateTotal();});}functionregisterSelectionChangeEvents(){vargrid=F(gridClientID);grid.on('selectionchange',function(cmp,selected){updateTotal();});}//页面第一次加载完成后调用的函数F.ready(function(){registerNumberChangeEvents();registerSelectionChangeEvents();updateTotal();});</script></body></html>
解决方案
解决方案二:
script里打alert确定有没运行
解决方案三:
引用1楼xdashewan的回复:
script里打alert确定有没运行
是//页面第一次加载完成后调用的函数F.ready(function(){registerNumberChangeEvents();registerSelectionChangeEvents();updateTotal();});没有运行
解决方案四:
引用1楼xdashewan的回复:
script里打alert确定有没运行
恩没有运行还有就是F.ready()这个东西没有运行
解决方案五:
把script放到head标签内,或者放到最下面的html下面。
解决方案六:
引用4楼guwei4037的回复:
把script放到head标签内,或者放到最下面的html下面。
放在head内出错,放在html下面还是更原来一样的效果示例原网站:http://fineui.com/demo/#/demo/grid/grid_edit_cart.aspx