显示剑道窗口时遇到困难。上传 CSV 文件时,我正在检查条件并调用"Import(("函数,该函数应该使用 kendo 模板打开一个窗口。但是当我尝试这样做时,我的 jQuery 选择器找不到窗口并返回"未定义"。我应该怎么做才能解决它?
包含div 内容的脚本
<script type="text/x-kendo-template" id="templateCondition">
<div id="details-container">
<p>*File's road lenght is not equal to selected Road's lenght .</p>
<p>Are you sure, you want to import the file?</p>
</div>
<button class="k-button" id="yesButton">Yes</button>
<button class="k-button" id="noButton"> No</button>
</script>
包含打开窗口的 import(( 函数的脚本
<script type="text/javascript">
var generateTemplateWindow =
kendo.template($("#templateCondition").html());
function Import() {
var wnd = $("#ConfirmationWindow").data("kendoWindow");
wnd.content(generateTemplateWindow);
wnd.center().open();
$("#yesButton").click(function() {
window.location = "SegIRI/InsertCsvFile";
wnd.close();
});
$("#noButton").click(function() {
wnd.close();
});
}
</script>
窗口剑道代码
@(Html.Kendo().Window().Name("ConfirmationWindow")
.Title("According to the following condition data will import")
.Visible(false)
.Modal(true)
.Draggable(true)
.Width(450)
.Height(100)
)
条件函数调用
if ((string) TempData["notice"] == "BC")
{
<script type="text/javascript">
Import();
</script>
}
错误消息的屏幕截图
试试这个。您可能需要为此指定 id。
@(Html.Kendo().Window().HtmlAttributes(new { id = "ConfirmationWindow" })
.Name("ConfirmationWindow")
...
)