8

ボタンをクリックすると、「Microsoft JScript ランタイム エラー: オブジェクトはプロパティまたはメソッド 'ライブ' をサポートしていません」というエラーが表示 されます。

@model Charis.Models.Products
@{
    ViewBag.Title = "Create";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<link href="../../Content/CharisSite.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
@using (Html.BeginForm("Create", "Prod", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
    @Html.ValidationSummary(true)
    <table><tr><td>
    <table>
    <tr>
    <td>
     <fieldset>
             <legend>Products</legend>

     <table>
        <tr>
        <td>
            <div class="editor-label">
            @Html.LabelFor(model => model.Productname)
            </div>
        </td>
        <td>
             <div class="editor-field">
            @Html.EditorFor(model => model.Productname)
            @Html.ValidationMessageFor(model => model.Productname)
            </div>
        </td>
        </tr>
        <tr>
        <td>
            <div class="editor-label">
                @Html.LabelFor(model => model.ProductPrice)
            </div>
        </td>
        <td>
            <div class="editor-field">
            @Html.EditorFor(model => model.ProductPrice)
            @Html.ValidationMessageFor(model => model.ProductPrice)
            </div>
        </td>
        </tr>
        <tr>
        <td>
            <div class="editor-label">
            @Html.LabelFor(model => model.ProductDiscount)
            </div>
        </td>
        <td>
            <div class="editor-field">
            @Html.EditorFor(model => model.ProductDiscount)
            @Html.ValidationMessageFor(model => model.ProductDiscount)
            </div>
        </td>
        </tr>

        <tr>
        <td>
            <div class="editor-label">
                @Html.LabelFor(model => model.LanguageType)
            </div>
        </td>
        <td>
             <div class="editor-field">
            @Html.EditorFor(model => model.LanguageType)
            @Html.ValidationMessageFor(model => model.LanguageType)
            </div>
        </td>
        </tr>

        <tr>
        <td>
             <div class="editor-label">
                @Html.LabelFor(model => model.ReleaseDate)
            </div>
        </td>
        <td>
                <div class="editor-field">
                         @Html.EditorFor(model => model.ReleaseDate)
                         @Html.ValidationMessageFor(model => model.ReleaseDate)
                </div>
        </td>
        </tr>
        <tr>
        <td>
             <div class="editor-label">

               <label for="file">Upload Image:</label>
            </div>
        </td>
        <td>
                <div class="editor-field">
                    <input type="file" name="file" id="file"/>
               </div>
        </td>
        </tr>

     </table> 

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

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



    <table>
    <tr>
    <td>
        <fieldset>
        <legend>Details</legend>
            <table>
                <tr>
                    <td>
                        <div class="editor-label">
                            @Html.LabelFor(model => model.AlbumDescription1)
                        </div>
                    </td>
                    <td>
                        <div class="editor-field">
                            @Html.EditorFor(model => model.AlbumDescription1)
                            @Html.ValidationMessageFor(model => model.AlbumDescription1)
                        </div>
                    </td>
                </tr>
                <tr>
                    <td>
                        <div class="editor-label">
                            @Html.LabelFor(model => model.AlbumDescription2)
                        </div>
                    </td>
                    <td>
                        <div class="editor-field">
                            @Html.EditorFor(model => model.AlbumDescription2)
                            @Html.ValidationMessageFor(model => model.AlbumDescription2)
                        </div>
                    </td>
                </tr>
                <tr>
                    <td>
                        <div class="editor-label">
                            @Html.LabelFor(model => model.Cast)
                        </div>
                    </td>
                    <td>
                        <div class="editor-field">
                            @Html.EditorFor(model => model.Cast)
                            @Html.ValidationMessageFor(model => model.Cast)
                        </div>
                    </td>
                </tr>
                <tr>
                    <td>
                        <div class="editor-label">
                            @Html.LabelFor(model => model.DirectedBy)
                        </div>
                    </td>
                    <td>
                        <div class="editor-field">
                            @Html.EditorFor(model => model.DirectedBy)
                            @Html.ValidationMessageFor(model => model.DirectedBy)
                        </div>
                    </td>
                </tr>
                <tr>
                    <td>
                        <div class="editor-label">
                            @Html.LabelFor(model => model.ProducedBy)
                        </div>
                    </td>
                    <td>
                        <div class="editor-field">
                            @Html.EditorFor(model => model.ProducedBy)
                            @Html.ValidationMessageFor(model => model.ProducedBy)
                        </div>
                    </td>
                </tr>

                <tr>
                    <td>
                        <div class="editor-label">
                           <label for="file">Upload Image1:</label>
                        </div>
                    </td>
                    <td>
                        <div class="editor-field">
                            <input type="file" name="file1" id="file1"/>
                        </div>
                    </td>
                </tr>

                <tr>
                    <td>
                        <div class="editor-label">
                           <label for="file">Upload Image2:</label>
                        </div>
                    </td>
                    <td>
                        <div class="editor-field">
                            <input type="file" name="file2" id="file2"/>
                        </div>
                    </td>
                </tr>

                <tr>
                    <td>
                        <div class="editor-label">
                           <label for="file">Upload Image3:</label>
                        </div>
                    </td>
                    <td>
                        <div class="editor-field">
                            <input type="file" name="file3" id="file3"/>
                        </div>
                    </td>
                </tr>

                <tr>
                    <td>
                        <div class="editor-label">
                           <label for="file">Upload Image4:</label>
                        </div>
                    </td>
                    <td>
                        <div class="editor-field">
                            <input type="file" name="file4" id="file4"/>
                        </div>
                    </td>
                </tr>

                <tr>
                    <td>
                        <div class="editor-label">
                           <label for="file">Upload Image5:</label>
                        </div>
                    </td>
                    <td>
                        <div class="editor-field">
                            <input type="file" name="file5" id="file5"/>
                        </div>
                    </td>
                </tr>

                <tr>
                    <td>
                        <div class="editor-label">
                            @Html.LabelFor(model => model.NoOfDisk)
                        </div>
                    </td>
                    <td>
                        <div class="editor-field">
                            @Html.EditorFor(model => model.NoOfDisk)
                            @Html.ValidationMessageFor(model => model.NoOfDisk)
                        </div>
                    </td>
                </tr>

                <tr>
                    <td>
                        <div class="editor-label">
                            @Html.LabelFor(model => model.Weight)
                        </div>
                    </td>
                    <td>
                        <div class="editor-field">
                            @Html.EditorFor(model => model.Weight)
                            @Html.ValidationMessageFor(model => model.Weight)
                        </div>
                    </td>
                </tr>

                <tr>
                    <td>
                        <div class="editor-label">
                            @Html.LabelFor(model => model.Format)
                        </div>
                    </td>
                    <td>
                        <div class="editor-field">
                            @Html.EditorFor(model => model.Format)
                            @Html.ValidationMessageFor(model => model.Format)
                        </div>
                    </td>
                </tr>

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



    </td></tr>

    <tr><td>
        <table><tr><td><fieldset><table>
            <tr>
                <td>
                <p>
                    <input type="submit" value="Create" />
                    <input type="button" value="Clear" id="btnClear" />
                </p>
                </td>
            </tr>
        </table></fieldset></td></tr></table>

    </td></tr>

    </table>

}

@*<div>
    @Html.ActionLink("Back to List", "Index")
</div>
*@
@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
}

@if (TempData["notice"] != null) 
{
<p style="color:Red;" >@TempData["notice"]</p>
}
4

3 に答える 3

15

廃止された最新のjquery(1.9 ...)を使用して$(sel).live(...)いるため、エラーメッセージが表示されます。

1) 古いバージョンの jquery に戻します。

2) コードを更新します (live を on に置き換えます)。

3) jquery-latest を元に戻します。

于 2013-02-08T14:39:33.050 に答える
2

自分でjQuery 1.9に更新した後、これに出くわしました。ただし、コードのどの部分がエラーを引き起こしているかを以前に指摘したユーザーは誰もいませんでした (説明のないリンクの AliRıza Adıyahşi を除く)。結局のところ、 $(sel).live(...)が推奨されなくなった場合$(sel).on(...)、それは非常に簡単な修正ですよね?

問題は、このエラーがjquery.unobtrusive-ajax.jsバンドルの一部として含まれている 内でスローされていることです@Scripts.Render("~/bundles/jqueryval")

Ajax フォームまたはキャンセルを使用していないため、エラーが何かに影響を与える可能性は低いですが (私の場合は影響しません)、Microsoft から修正について何も見つけることができませんでした。残念ながら、修正は、MS が公式のものを修正するまで、.on() への .live 呼び出しを置き換える jquery.unobtrusive-ajax.js のバージョンを修正することです。

于 2013-04-19T20:38:18.307 に答える