If there's no defined callout for the specified launch point the error will be raised.

getFromLaunchPointIfExists

It's the variation of the getFromLaunchPoint (see above) method. The only difference is that there will be no error if the callout isn't founded. In that case the method simply returns null. it allows to check for the existence of the callout instance silently.

getFromCalloutDescendant

This method allows to get a callout instance from the DOM element located inside it's structure. It allows for example to get the callout from its content. The only argument is the DOM element. If the chosen DOM element is not inside the callout or the callout is not found for the some reason the error will be raised.

How to Create a Callout

There are two methods to create a callout. Both methods accept a callout creation options object and return the created callout instance. For the details of the creation see the first article of the series.

createNew

The method createNew which allows to create a callout is described in the first part of this series.

createNewIfNecessary

The method createNewIfNecessary is almost identical to the createNew but creates the callout only if there's no callout for the target launch point already. If there's a callout it will be returned instead of the creation of the new one.

var callout = CalloutManager.createNewIfNecessary(calloutOptions);

How to Remove a Callout

If you need to remove the callout you need to pass it to the remove method of the CalloutManager:

And here’s the result (for the callout creation see the previous article):

Here we’ve defined the required minimum of options – the text and the click event handler.

text

The text is required option. It’s a string.

onClickCallback

It’s the function that handles the action click event. It is required if your action is simple and it doesn’t have any menu items (see below for the menu action details). This function receives two arguments. First argument is the standard HTML DOM event caused by the click on the action. The second parameter is the action itself:

Actions with the dropdown menu

The last but not least option for the action configuration is the menuEntries property of the CalloutActionOptions object. It helps to define a special kind of the action – the one with the dropdown menu of options instead of a simple text. It allows combining several actions in the related and compact groups in order to save space, providing some logical structure for the actions list and adhering to the SharePoint Metro UI design principles.

If there are any items in the menuEntries, the action becomes a dropdown menu. In that case you can’t set the action’s onClickCallback handler because the action no more responsible for any real work and only expands its dropdown menu on click event.

menuEntries is just a standard JavaScript array containing CalloutActionMenuEntry instances. Each element corrensponds to a single menu item. Here’s the initialization example:

The minimal parameters for each action menu entry are the text and the onClickCallback function. It’s not practical anyway but if you don’t provide them the whole action will not be shown and the error will be raised.

text

It’s the text of the menu entry.

onClickCallback

It’s the handler function for the menu entry click event. This function receives two arguments. First argument is the parent action of the clicked menu entry and the second one is the zero based index of the entry itself inside menuEntries array. The combination of these parameters allows getting the clicked entry:

For the menu action the text option of the CalloutActionOptions is not required. If it doesn’t defined there will be ellipsis image drawn instead of the text:

The common design is to have a single menu at the end of the row but there are no restrictions on the menu position and quantity of menus inside the actions row. You can create multiple menus but I think it doesn’t adhere to the SharePoint Metro UI design.

Unresolved questions

There are some questions that need to be resolved still.

The CalloutActionMenuEntry class accepts four additional parameters: image url, image alt text, “sequence” and “description”. They all results in some HTML markup inside the generated menu item but it is unclear how they are used. For example, if you provide the image url correspondinf image will be rendered in menu item HTML but will be hidden.

There are some out-of-the-box callouts with additional customizations of action dropdown menu. For example, here are the separators:

It appears that the separators generation is implemented outside the “core” callouts UI framework. Can it be reused?