Creating a Message

As we just discussed, there are three different message types that we can create within a gadget, each of which has its own specific expiration criteria. Let’s go over them in more depth.

Dismissible messages

The dismissible message window is a standard alert that, if it’s not programmatically set to close, requires the user to interact with the window dismiss controls (generally an “x” in the top-right corner) to close it. These messages are generally developed to alert the user of changes within the gadget—such as new messages for her, or profile detail changes requesting an accept or cancel action from her.

We can create a dismissible mini-message simply by following the requirements described previously:

<Module title="Gadget to display a mini-message">
      <Require feature="minimessage" />
   <Content view="canvas">
      <div id="msgDisplay"></div>

      <script type="text/javascript">
      //message dismissal callback
      function msgCallback(){
         document.getElementById("msgDisplay").innerHTML = "Message window closed";

      //create new dismissible mini-message
      var message = new gadgets.MiniMessage(__MODULE_ID__);
      message.createDismissibleMessage("My dismissible mini-message", msgCallback);

We add in our Require element to enable the minimessage JavaScript ...

Get Programming Social Applications now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.