jQuery form的load函數與el運算式賦值的衝突問題

來源:互聯網
上載者:User

標籤:

問題:

在使用el運算式給表單中的項賦初始值的時候,總是失敗,物流公司沒有自動選中,物流單號也沒有顯示值。

 

<form id="form" method="post">
。。。。
<
tr> <th>物流公司:</th> <td> <select id="shippingCompany" name="shippingCompany" class="easyui-combobox" style="width: 171px;" data-options="required:true"> <c:choose> <c:when test=‘${not empty brand}‘> <c:forEach var="lc" items="${logisticsCorporations}"> <c:choose> <c:when test=‘${brand.shippingCompany eq lc.logisticsId}‘> <option value="${lc.logisticsId }" selected="selected">${lc.logisticsName }</option> </c:when> <c:otherwise> <option value="${lc.logisticsId }" >${lc.logisticsName }</option> </c:otherwise> </c:choose> </c:forEach> </c:when> <c:otherwise> <c:forEach var="lc" items="${logisticsCorporations}"> <option value="${lc.logisticsId }" >${lc.logisticsName }</option> </c:forEach> </c:otherwise> </c:choose> </select> </td></tr><tr> <th>物流單號:</th> <td><input name="shippingSn" id="shippingSn" class="easyui-textbox easyui-validatebox" type="text" value="${brand.shippingSn }" required="required"/></td></tr>
</form>

 

調查:

1、當我把class="easyui-combobox"和class="easyui-textbox easyui-validatebox"屬性去掉以後,就正常了。懷疑是easyui衝突了。

2、當我把form標籤刪掉,或者把form的id屬性改個名字,也正常了,懷疑是jQuery在使用form的時候造成的衝突。

3、繼續調查,當前頁面其實是一個編輯頁面,它是這樣在父頁面中被開啟的:

//發貨function ship() {    var row = $dg.datagrid(‘getSelected‘);    if (row) {        parent.$.modalDialog({            title : ‘編輯訂單資訊‘,            width : 600,            height : 270,            href : "${pageContext.request.contextPath}/orders/showShip?orderId="+row.orderId+"&orderInfoId="+row.orderInfoId,            onLoad:function(){                var f = parent.$.modalDialog.handler.find("#formx");                f.form("load", row);            },            buttons : [ {                text : ‘確定‘,                iconCls : ‘icon-ok‘,                handler : function() {                    parent.$.modalDialog.openner= $grid;//因為添加成功之後,需要重新整理這個dataGrid,所以先預定義好                    var f = parent.$.modalDialog.handler.find("#form");                    f.submit();                }            }, {                text : ‘取消‘,                iconCls : ‘icon-cancel‘,                handler : function() {                    parent.$.modalDialog.handler.dialog(‘destroy‘);                    parent.$.modalDialog.handler = undefined;                }            }            ]        });    }else{        parent.$.messager.show({            title :"提示",            msg :"請選擇一行記錄!",            timeout : 1000 * 2        });    }}

dg是一個datagrid表格,我們的編輯頁面就是編輯dg選中的一行資料。注意onLoad方法,在資料載入完畢以後,有一個f.form("load",row)方法,該方法能夠自動將這行資料的各屬性值填充到編輯頁面的相應表單項中。

這本質上與我們在編輯頁面中使用el運算式給表單項賦值就衝突了,也就是說,你要麼使用f.form("load",row)給表單項賦值,要麼使用el運算式給表單項賦值,只能選一個。

解決:

去掉onLoad方法。

 

jQuery form的load函數與el運算式賦值的衝突問題

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.