gpt4 book ai didi

c# - 在 MVC 4 中使用 jquery 工具提示

转载 作者:太空宇宙 更新时间:2023-11-03 10:48:33 25 4
gpt4 key购买 nike

我正在使用 MVC 4(C# with razor)并且我在我的页面中添加了一个 jquery datepicker,它工作正常。

我现在想添加一个工具提示,这是我在下面的代码中完成的。

        <div class="editor-label">
@Html.LabelFor(model => model.Rating)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Rating, new { title = "Rating" })
@Html.ValidationMessageFor(model => model.Rating)
</div>

<div class="editor-label">
@Html.LabelFor(model => model.ReleaseDate)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.ReleaseDate, new { id = "ReleaseDate" })
@Html.ValidationMessageFor(model => model.ReleaseDate)
</div>

以脚本为

<script type="text/javascript">

$(function () {
$('#ReleaseDate').datepicker({ dateFormat: "dd-mm-yy" });
$( document ).tooltip();
});

日期选择器工作正常,但工具提示没有任何反应,有什么想法吗?

这是 View 的完整页面代码

  @model testpage.Models.Game

@{
ViewBag.Title = "Create";
}
<link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/themes/smoothness/jquery-ui.css" />
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js"></script>

<h2>Create</h2>

@using (Html.BeginForm()) {
@Html.AntiForgeryToken()
@Html.ValidationSummary(true)

<fieldset>
<legend>Game</legend>

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

<div class="editor-label">
@Html.LabelFor(model => model.Rating)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Rating, new { @title = "Rating" })
@Html.ValidationMessageFor(model => model.Rating)
</div>

<div class="editor-label">
@Html.LabelFor(model => model.ReleaseDate, "Release Date")
</div>


<div class="editor-field">
@Html.EditorFor(model => model.ReleaseDate, new { id = "ReleaseDate" })
@Html.ValidationMessageFor(model => model.ReleaseDate)
</div>

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

<p>
<input type="submit" value="Create" />
</p>
</fieldset>
}

<div>
@Html.ActionLink("Back to List", "Index")
</div>

<script type="text/javascript">

$(function () {
$('#ReleaseDate').datepicker({ dateFormat: "dd-mm-yy" });
$( document ).tooltip();
});


</script>

@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}

最佳答案

在谷歌上幸运地发现工具提示不适用于 editorfor 所以我将其更改为 TextBoxfor 并且效果很好

关于c# - 在 MVC 4 中使用 jquery 工具提示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22440435/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com