我正在使用ASP.NET CORE开发网站,并使用rateYo脚本。
如何最好地实现多次加载和更改事件的方式。
下面我的代码比我需要的更好,因为它创建了多个脚本
<form id="skillRatingForm" onsubmit="return false;">
<a>Bla bla</a>
<br/>
<br/>
<fieldset>
<div class="form-group col-md-12">
@{
for (int i = 0; i < Model.SkillsList.Count; i++)
{
<div class="row form-group col-md-6">
<div>
<label>@Model.SkillsList[i].Name</label>
<div id="rateLanguage_@i"></div>
<input id="rateLanguageScore_@i" type="hidden" asp-for="@Model.SkillsList[i].Rate" />
<input type="hidden" asp-for="@Model.SkillsList[i].SkillId" />
<input type="hidden" asp-for="@Model.SkillsList[i].Id" />
</div>
<hr/>
</div>
}
}
</div>
<input type="hidden" asp-for="@Model.ResumeId" />
<div class="buttons pull-right ">
<input type="submit" class="width-s btn btn-success" onclick="postModal('skillRatingForm', '@Url.Action("RatingSkillPartial", "ResumePartials")', 'skillInfo')" value="Kaydet"/>
<input type="submit" class="width-c btn btn-danger" data-dismiss="modal" value="İptal"/>
</div>
</fieldset>
</form>
</div>
<script>
@for (int i = 0; i < @Model.SkillsList.Count; i++)
{
string modelRating = Model.SkillsList[i].Rate >= 0 ? @Model.SkillsList[i].Rate.ToString("") : "0";
<text>
$("#rateLanguage_@i").rateYo({
rating: @modelRating
});
$("#rateLanguageScore_@i").val(@modelRating);
$("#rateLanguage_@i").rateYo().on("rateyo.change",
function (e, data) {
var rating = data.rating;
$("#rateLanguageScore_@i").val(rating);
});
</text>
}
</script>
答案 0 :(得分:0)
在您的页面中创建类似的内容: