单击按钮清除推送通知
Clearing push notifications onClick button
我在rails应用程序中有一个通知按钮,可以列出朋友最近的活动。它有一个计数徽章,出现在按钮上方。一旦用户查看了这些通知,我想清除当前徽章,这样计数就可以用新的通知重新开始。有什么建议吗?
var renderActivities = function() {
var source = $('#activities-template').html();
var template = Handlebars.compile(source);
var html = template({
activities: window.loadedActivities,
count: window.loadedActivities.length
});
我在尝试这样的东西:
$('#notifications-button').click(function(event) {
count: = 0;
});
源代码(体外):
<script id="activities-template" type="text/x-handlebars-template">
<button class="btn btn-default" class="dropdown-toggle notifications-button" data-toggle="dropdown"><i class="fa fa-bell-o fa-2x"><span class="badge notifications-count">{{count}}</span></i></button>
<ul class="dropdown-menu pull-right notifications-menu">
{{#each activities}}
{{activityLink}}
{{/each}}
<li class="divider"></li>
<li><a href="{{activityFeedLink}}" class="center">See All</a></li>
</ul>
</script>
我真的不太熟悉Javascript,但真的需要这个功能来工作。
您需要获取包含计数的选择器,并将文本设置为0
。类似…
$('#notifications-button').on('click', function() {
$('.notifications-count').text('0');
});
相关文章:
- document.open/document.write没有正确地清除chrome中的文档——这是chrome的错误吗
- 单击jquery清除输入值
- Firebase2(Firebase.google.com)推送通知-从外部管理
- 如何在Microsoft VirtualEarth 6.3中使用纯javascript清除整个形状层
- 清除以前的$_GET值或不获取仅隐藏字段的值
- 无法在窗口内使用rootScope.通知
- JS,用于播放提示音以通知未按预期工作
- Javascript清除缓存以清除基本身份验证凭据
- 单击Chrome通知后,转到已打开的选项卡
- Windows Azure通知中心错误
- 清除启动日期选取器值
- 在 SlickGrid 中编辑后,根据不同列中的另一个单元格清除单元格
- php页面,该页面在清除值后接受输入
- 清除数据并将旧值附加到文本框中
- 单击按钮清除推送通知
- Notify.js清除旧通知
- Phonegap应用程序清除推送通知不起作用
- 清除通知,点击/切换()
- 清除系统通知
- Azure移动服务推送磁贴通知和清除磁贴属性