2014-08-27 19 views
1

我有一個MVC視圖(下面的部分示出):JQuery的.Find()在IE11和鉻不工作在搜索MVC編輯模板元素時

<div class="section roundedbox" id="results"> 
    <div class="section-title roundedbox center ui-widget-header">@Html.LabelFor(p => p.SOWProductCodes)</div> 
    <div class="section-content ui-widget-content"> 
     @if (Model.SOWProductCodes.Count > 0) 
     { <table class="list"> 
      <thead> 
       <tr> 
        <th style="width: 5%" class="center"> 
         Remove 
        </th> 
        <th style="width: 50%">@Html.LabelFor(p => p.SOWProductCodes[0].ProductCodename) 
        </th> 
        <th style="width: 30%">@Html.LabelFor(p => p.SOWProductCodes[0].BoxMaterial) 
        </th> 
        <th style="width: 5%"> 
         Save 
        </th> 
       </tr> 
      </thead> 
      <tbody> 
       @Html.EditorFor(p => p.SOWProductCodes, new 
       { 
        SOWId = Model.SOWId 
       }) 
      </tbody> 
     </table> } 
     else 
     { 
      <div class="center"> 
       No related products codes found.<br /> 
       At least one product code must exist to continue.</div> 
     } 
    </div> 
</div> 

它引用了以下編輯模板:

@model Product.Web.Models.ProductCode 
<tr> 
<td style="width: 5%" class="center"> 
    @using(Html.BeginForm("RemoveProductCode", "Details", FormMethod.Post)) 
    { 
     <input type="hidden" value="@Model.ProductCodeId" name="ProductCodeId"/> 
     <input class="center" id="remove" type="image" value="Remove" src="@Url.Content("~/Content/images/Cancel.png")" width="24px" height="24px" alt="Remove" /> 
    } 
</td> 
@using(Html.BeginForm("UpdateProductCode", "Details", FormMethod.Post)) 
{ 
    <td style="width: 50%"> 
     <input type="text" value="@Model.ProductCodename" name="ProductCodename"/> 
    </td> 
    <td style="width: 45%"> 

     <input type="text" value="@Model.BoxMaterial" name="BoxedMaterial"/> 
    </td> 
    <td style="width: 5%" class="center"> 
     <input type="hidden" value="@ViewBag.SOWId" name="SOWId"/> 
     <input type="hidden" value="@Model.ProductCodeId" name="ProductCodeId"/> 
     <input class="right" id="save" type="image" value="Update" src="@Url.Content("~/Content/images/Ball Green Check.png")" width="24px" height="24px" alt="Update" /> 
    </td> 
} 
</tr> 

以下JQuery適用於所有未使用編輯器模板的視圖(通過IE11)。對於上述觀點它工作在IE11但在IE 9模式下使用F12,只有當:

/toggles chages on input change 
$('input, textarea, select').live('change', function (element) { ToggleChange(true, element); });}); 

function ToggleChange(changed, element) { 
var form = element.currentTarget.form; 

if (changed) { 
    $('#changed').html('*'); 
    //Enable save 
$(form).find('input[id="save"]').removeAttr('disabled'); 
$(form).find('input[id="save"]').show(); 
    $(form).find('img[id="warning"]').hide(); 
} 
else { 
    $('#changed').html(''); 
    //disable save 
    $(form).find('input[id="save"]').hide(); 
    $(form).find('input[id="save"]').attr('disabled', 'disabled'); 
}; 
} 

我能夠通過使用$(「輸入[ID =‘保存’]」),以使輸入表演秀。 ()。然而,上面的JQuery是全局使用的,因此我傳遞了包含我想要顯示/隱藏的「保存」輸入的表單。

這是工作,直到客戶開始升級到IE10及以上。我記得它也適用於早期版本的Chrome。

+0

什麼版本的jQuery? '.live()'在1.7中折舊並在1.9中被移除。 – 2014-08-28 01:30:17

+0

我使用的是1.7.1版本,只是爲了確保我更新爲使用.on()代替.live()。仍然看到相同的問題。 – Racter 2014-09-02 15:15:09

回答

1

在本節:

</td> 
@using(Html.BeginForm("UpdateProductCode", "Details", FormMethod.Post)) 
{ 
    <td style="width: 50%"> 

您的表單代碼表明瞭TD標記之間。

+0

你是對的。我把表單放在一個新的單元格中,然後在該單元格內的一個新表格周圍添加表單,現在它可以工作。 – Racter 2014-09-03 23:37:16