Jquery 如何在剑道通知中传递autoHideAfter
我正在应用程序中创建泛化通知。因为我必须用不同的时间间隔来传递显示剑道通知的时间Jquery 如何在剑道通知中传递autoHideAfter,jquery,html,kendo-ui,notifications,Jquery,Html,Kendo Ui,Notifications,我正在应用程序中创建泛化通知。因为我必须用不同的时间间隔来传递显示剑道通知的时间 <div id="appendNotification" class="k-animation-container k-state-border-down" style="margin: 0px; padding: 0px 0px 4px; overflow: visible; position: fixed; top: 5%; z-index: 10002; right: 2%;"></div&
<div id="appendNotification" class="k-animation-container k-state-border-down" style="margin: 0px; padding: 0px 0px 4px; overflow: visible; position: fixed; top: 5%; z-index: 10002; right: 2%;"></div>
<span id="popupNotification"></span>
&我的剑道通知代码如下所示
var notificationElement = $("#popupNotification");
window.notificationElement.kendoNotification({
appendTo: "#appendNotification",
autoHideAfter: 5000,
templates: [{
type: "success",
template: GetNotificationTemplate("#= notificationHeader #","#= notificationMessage #")
},
{
type: "warning",
template: GetNotificationTemplate("#= notificationHeader #", "#= notificationMessage #")
},
{
type: "info",
template: GetNotificationTemplate("#= notificationHeader #", "#= notificationMessage #")
},
{
type: "error",
template: GetNotificationTemplate("#= notificationHeader #", "#= notificationMessage #")
}]
});
var nspSendCommonNotification = window.notificationElement.data("kendoNotification");
var container = $(nspSendCommonNotification.options.appendTo);
container.scrollTop(container[0].scrollHeight);
function GetNotificationTemplate(headerTextValue, contentTextValue) {
return "<div style=\"padding:5px\"><span class='k-icon k-i-close nspNotificationClose nspNotificationCross' style=\"float: right;\"></span><h3>" + headerTextValue + "</h3><p style='margin:0px;width: 250px;'>" + contentTextValue + "</p></div>";
}
var notificationElement=$(“#popupNotification”);
window.notificationElement.kendNotification({
附件:“#附件通知”,
自动隐藏时间:5000,
模板:[{
键入:“成功”,
模板:GetNotificationTemplate(“#=notificationHeader#”,“#=notificationMessage#”)
},
{
键入:“警告”,
模板:GetNotificationTemplate(“#=notificationHeader#”,“#=notificationMessage#”)
},
{
输入:“信息”,
模板:GetNotificationTemplate(“#=notificationHeader#”,“#=notificationMessage#”)
},
{
键入:“错误”,
模板:GetNotificationTemplate(“#=notificationHeader#”,“#=notificationMessage#”)
}]
});
var nspSendCommonNotification=window.notificationElement.data(“kendoNotification”);
var container=$(nspSendCommonNotification.options.appendTo);
container.scrollTop(容器[0].scrollHeight);
函数GetNotificationTemplate(headerTextValue、contentTextValue){
返回“+headerTextValue+”“+contentTextValue+”
”;
}
所以我需要动态地传递autoHideAfter是否可能
您可以在以下位置找到问题:您可以尝试以下方法: 放置时间间隔的数据属性并附加到目标范围中的值(在本例中,目标范围是
popupNotification
)
并修改jquery:
var notificationElement = $("#popupNotification");
window.notificationElement.kendoNotification({
appendTo: $(this).data('appendto'),// read append to data
autoHideAfter: $(this).data('time'),// read time interval data
templates: [{
type: "success",
template: GetNotificationTemplate("#= notificationHeader #","#= notificationMessage #")
},
{
type: "warning",
template: GetNotificationTemplate("#= notificationHeader #", "#= notificationMessage #")
},
{
type: "info",
template: GetNotificationTemplate("#= notificationHeader #", "#= notificationMessage #")
},
{
type: "error",
template: GetNotificationTemplate("#= notificationHeader #", "#= notificationMessage #")
}]
});
var nspSendCommonNotification = window.notificationElement.data("kendoNotification");
var container = $(nspSendCommonNotification.options.appendTo);
container.scrollTop(container[0].scrollHeight);
function GetNotificationTemplate(headerTextValue, contentTextValue) {
return "<div style=\"padding:5px\"><span class='k-icon k-i-close nspNotificationClose nspNotificationCross' style=\"float: right;\"></span><h3>" + headerTextValue + "</h3><p style='margin:0px;width: 250px;'>" + contentTextValue + "</p></div>";
}
var notificationElement=$(“#popupNotification”);
window.notificationElement.kendNotification({
appendTo:$(this.data('appendTo'),//读取附加到数据
autoHideAfter:$(this).data('time'),//读取时间间隔数据
模板:[{
键入:“成功”,
模板:GetNotificationTemplate(“#=notificationHeader#”,“#=notificationMessage#”)
},
{
键入:“警告”,
模板:GetNotificationTemplate(“#=notificationHeader#”,“#=notificationMessage#”)
},
{
输入:“信息”,
模板:GetNotificationTemplate(“#=notificationHeader#”,“#=notificationMessage#”)
},
{
键入:“错误”,
模板:GetNotificationTemplate(“#=notificationHeader#”,“#=notificationMessage#”)
}]
});
var nspSendCommonNotification=window.notificationElement.data(“kendoNotification”);
var container=$(nspSendCommonNotification.options.appendTo);
container.scrollTop(容器[0].scrollHeight);
函数GetNotificationTemplate(headerTextValue、contentTextValue){
返回“+headerTextValue+”“+contentTextValue+”
”;
}
尝试类似的逻辑来动态配置剑道通知。你能发布你的问题的JSFIDLE吗?你可以在JSFIDLE上显示问题:你想在页面加载时或在任何特定实例上传递不同的时间间隔吗?从我调用它的任何时候开始,我想传递时间间隔,而不是静态地应用它。所以创建一个变量并根据您的要求分配或更改其时间间隔值,并对“autoHideAfter”使用相同的变量。看到这里,让我试试这些,但我认为它们的行为也类似于您建议我使用的全局参数。对于您的clearification,我只调用这些不同的头和消息:
nspSendCommonNotification.info({notificationHeader:'Hello',notificationMessage:'Hi'})
在每个调用中&那些span&code在_layout.cshtml页面中需要通过添加参数来传递此调用中的时间间隔:nspSendCommonNotification.info({notificationHeader:'Hello',notificationMessage:'Hi'})代码>这可能吗???
var notificationElement = $("#popupNotification");
window.notificationElement.kendoNotification({
appendTo: $(this).data('appendto'),// read append to data
autoHideAfter: $(this).data('time'),// read time interval data
templates: [{
type: "success",
template: GetNotificationTemplate("#= notificationHeader #","#= notificationMessage #")
},
{
type: "warning",
template: GetNotificationTemplate("#= notificationHeader #", "#= notificationMessage #")
},
{
type: "info",
template: GetNotificationTemplate("#= notificationHeader #", "#= notificationMessage #")
},
{
type: "error",
template: GetNotificationTemplate("#= notificationHeader #", "#= notificationMessage #")
}]
});
var nspSendCommonNotification = window.notificationElement.data("kendoNotification");
var container = $(nspSendCommonNotification.options.appendTo);
container.scrollTop(container[0].scrollHeight);
function GetNotificationTemplate(headerTextValue, contentTextValue) {
return "<div style=\"padding:5px\"><span class='k-icon k-i-close nspNotificationClose nspNotificationCross' style=\"float: right;\"></span><h3>" + headerTextValue + "</h3><p style='margin:0px;width: 250px;'>" + contentTextValue + "</p></div>";
}