首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Gritter标题、文本、图像

Gritter标题、文本、图像
EN

Stack Overflow用户
提问于 2012-01-27 09:42:52
回答 1查看 501关注 0票数 2

我有3个条件,可以渲染3个不同的gritter通知。条件结果应更改图像、文本和标题。我必须为每个条件执行$.gritter.add({...})吗?

或者,有没有一种方法可以在满足任何条件之前只声明一个gritter通知,然后在每个条件中设置标题、文本、图像,因为它们可能适用于该条件?

似乎从$.gritter.add({...})返回的唯一值是一个唯一的id,这对于删除非常有用,但乍一看,我并没有看到通过检查firebug中的DOM来添加gritter项的方法。

任何帮助我们都将不胜感激

EN

回答 1

Stack Overflow用户

发布于 2016-08-29 00:02:45

我知道这是几年后的事了,但这就是如何更改gritter的属性/值:

代码语言:javascript
复制
var unique_id = $.gritter.add({
    // (string | mandatory) the heading of the notification
    title: '<i class="fa fa-4x fa-bell"></i>&nbsp;&nbsp;New Page Enhancement!',
    // (string | mandatory) the text inside the notification
    text: 'Visit "New Page Enhancements" by clicking on the notifications icon.',
    // (string | optional) the image to display on the left
    image: '../images/logo.png',
    // (bool | optional) if you want it to fade out on its own or just sit there
    sticky: true,
    // (int | optional) the time you want it to be alive for before fading out
    time: '',
    // (string | optional) the class name you want to apply to that specific message
    class_name: 'my-sticky-class'
});

可以根据您计划推出的每个gritter实例来命名unique_id。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9027999

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档