unmount() & getPlacements()
Remove a specific placement by ID with unmount(), or inspect all currently mounted placements with getPlacements() to manage the full placement lifecycle.
After you mount a placement with mount(), the SDK gives you a placement ID you can use to remove it later. unmount() takes that ID and cleanly removes the placement from the DOM. getPlacements() returns a snapshot of everything currently mounted, useful for auditing state or building dynamic UIs that react to placement changes.
unmount(id)
unmount(id: string): voidRemoves a mounted placement from the page by its ID. The placement container is removed from the DOM and all associated event listeners are cleaned up. The placement ID becomes invalid after this call.
Parameters
idstringRequiredThe placement ID returned by mount(). Store this value if you plan to unmount the placement later.
getPlacements()
getPlacements(): PlacementInfo[]Returns an array of all placements currently mounted by the SDK. Each entry includes the placement's ID, type, and the DOM element hosting it. This call is safe to make at any time after initialization; it returns an empty array if no placements are mounted.
Return value
placementsPlacementInfo[]An array of objects describing each currently mounted placement.
Full lifecycle example
The pattern below shows the complete mount-inspect-unmount lifecycle:
var { Placement } = window.InlineAI;
// Mount and store the placement ID
var id = window.InlineAI.mount(Placement.BasicEmbed, 'sidebar');
// Inspect all currently mounted placements
var placements = window.InlineAI.getPlacements();
placements.forEach(function(p) {
console.log(p.id, p.type);
});
// Unmount by ID
window.InlineAI.unmount(id);Unmounting on route change (SPA example)
var { Placement, Events } = window.InlineAI;
var mountedId;
function mountForRoute(route) {
// Remove previous placement if one exists
if (mountedId) {
window.InlineAI.unmount(mountedId);
mountedId = undefined;
}
if (route.hasArticle) {
mountedId = window.InlineAI.mount(Placement.KeyTakeaways, 'article-sidebar');
}
}
// React to search overlay open: log the placement that was active
window.InlineAI.on(Events.SearchOpen, function(data) {
var placements = window.InlineAI.getPlacements();
console.log('Active placements when search opened:', placements.length);
});Unmounting all placements manually
If you need to remove every placement without calling destroy() (which also tears down the SDK), iterate over getPlacements():
window.InlineAI.getPlacements().forEach(function(p) {
window.InlineAI.unmount(p.id);
});