简体   繁体   中英

Creating a Notification Icon with Dojo 1.9

I want to create a notification icon with Dojo, but I'm not sure where to start. The icon has to be similar to those found on Facebook and Whatsapp, showing how many new messages/notifications you have.

I've been looking in the Dojo reference, but couldn't find a good widget to use. Maybe I'm missing something obvious, but I might as well ask it here.

Googling hasn't been of much use unfortunately.

As far as I know there's no widget that automatically does the stuff for you. This problem is far too specific to provide a general widget for it. You also have to think about several things before you can start.

  1. Do you want to use WebSockets ? The web is generally made for pulling content, if you want to push your notifications from your server to your client, then you will need to look at WebSockets . A good tutorial to use them can be found on Sitepen .

  2. If you don't want to use websockets (you're not able to create a websocket server or you have some other reasons) then you will probably have to use a simple "REST service" and obtain the amount of notifications from it. This means you're script won't be "live", so you will need to pull the content from the webservice every X seconds/minutes. This means you need a normal AJAX request which can be done with the dojo/request/script module. If you need to time this AJAX request, you can use the dojox/timing module.

This is only the "logic" part, the user interface (icon + # notifications) can be made by yourself with plain HTML and CSS.

What about dojox/mobile/Badge:

http://livedocs.dojotoolkit.org/dojox/mobile/Badge

?

From comment: "Maybe you can find something in the DojoX library" - off course you will find much.

I would recommend

dojox/socket

see http://dojotoolkit.org/features/1.6/dojo-websocket

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM