有没有办法通过 class 而不是 ID 来引用 kendo window?
Is there a way to reference a kendo window by class instead of ID?
标题几乎说明了一切。我像这样将 class 添加到 Kendo Window(试图使其通用)
@(Html.Kendo().Window()
.Name("modal")
.HtmlAttributes(new { @class = "kendo-modal" })
.Visible(false)
.Modal(true))
我似乎无法用 jQuery 引用它。当我尝试这样做时
$(".kendo-modal").data("kendoWindow").close();
我收到 "cannot read property 'close' of null" 错误
所以...将 class 放入 cshtml 代码中无效
@(Html.Kendo().Window()
.Name("modal")
.HtmlAttributes(new { @class = "kendo-modal" })
.Visible(false)
.Modal(true))
将其添加到 javascript 中的模态
$("#modal").addClass("kendo-modal").data("kendoWindow")
.title("Add Comment")
.refresh().center().open();
通常,如果您在 window 中有一个选择器,因为我猜这就是您想要做的,(可能是单击 window 中的按钮关闭此 window) 你可以使用最近的 k-window 来找到正确的元素
$( buttonInsideWindow ).closest(".k-window-content").data("kendoWindow").close();
记住这一点很有帮助。
标题几乎说明了一切。我像这样将 class 添加到 Kendo Window(试图使其通用)
@(Html.Kendo().Window()
.Name("modal")
.HtmlAttributes(new { @class = "kendo-modal" })
.Visible(false)
.Modal(true))
我似乎无法用 jQuery 引用它。当我尝试这样做时
$(".kendo-modal").data("kendoWindow").close();
我收到 "cannot read property 'close' of null" 错误
所以...将 class 放入 cshtml 代码中无效
@(Html.Kendo().Window()
.Name("modal")
.HtmlAttributes(new { @class = "kendo-modal" })
.Visible(false)
.Modal(true))
将其添加到 javascript 中的模态
$("#modal").addClass("kendo-modal").data("kendoWindow")
.title("Add Comment")
.refresh().center().open();
通常,如果您在 window 中有一个选择器,因为我猜这就是您想要做的,(可能是单击 window 中的按钮关闭此 window) 你可以使用最近的 k-window 来找到正确的元素
$( buttonInsideWindow ).closest(".k-window-content").data("kendoWindow").close();
记住这一点很有帮助。