Getters
title
get title(): string
Alias of placement. Returns the placement title ('DEFAULT' when no title was provided by the parent window).
placement
get placement(): string
Returns the placement title. By default, returns 'DEFAULT' if the title is not set.
isDefault
get isDefault(): boolean
Returns true if the placement title is 'DEFAULT'.
options
get options(): any
Returns the placement options object. The object is frozen to prevent modifications.
The object carries whatever the portal put in PLACEMENT_OPTIONS — including
every parameter you passed to
slider.openSliderAppPage,
which is how place reaches the new frame.
PLACEMENT_OPTIONS does not always arrive as an object. A portal can deliver it
as a JSON string, and key case is not guaranteed to be identical across entry
points. Reading options?.place off a string returns undefined — with no error
anywhere, and a symptom indistinguishable from the parameter never arriving.
Parse defensively, and consider reading the frame URL query as a fallback.isSliderMode
get isSliderMode(): boolean
Returns true if the widget is operating in slider mode (option IFRAME is 'Y').
It is derived from PLACEMENT_OPTIONS.IFRAME, so do not use it to decide
whether placement data arrived at all. Gating slider diagnostics on it is a
trap: the flag is computed from the very data whose absence you would be trying
to diagnose, so the log line goes quiet exactly when you need it.
// ... /////
$b24 = await initializeB24Frame()
// ... /////
if ($b24.placement.isSliderMode) {
$b24.parent.setTitle('SliderMode') // updates the layout #pagetitle, not the slider header or browser tab
}
Methods
getInterface
async getInterface(): Promise<any>
Getting information about the JS interface of the current embedding location: a list of possible commands and events.
// ... /////
$b24 = await initializeB24Frame()
// ... /////
const value: any = await $b24.placement.getInterface()
bindEvent
async bindEvent(
eventName: string,
callBack: (...args: any[]) => void
): Promise<any>
Setting up the event handler for the interface.
call
async call(command: 'setValue', parameters: { value: string }): Promise<any>
async call(command: string, parameters?: Record<string, any>): Promise<any>
Call the registered interface command.
import { LoggerFactory } from '@bitrix24/b24jssdk'
// ... /////
const logger = LoggerFactory.createForBrowser('Demo', true)
$b24 = await initializeB24Frame()
// ... /////
$b24.placement.call('reloadData')
.then((respose: any) => {
logger.info('reload call')
})
setValue command is special: the parent window calls JSON.parse(value)
on the received payload, so valuemust be a JSON-serialized string. Passing
a raw string or an object directly will fail (SyntaxError from
JSON.parse, or silent corruption to "[object Object]").Prefer the setValue helper, which serializes for you. If you use
call('setValue', ...) directly, the SDK will throw a TypeError when value
is not a string.// ✗ throws TypeError — value is not a string
await $b24.placement.call('setValue', { value: 'test' })
// ✓ works — value is a JSON string
await $b24.placement.call('setValue', { value: JSON.stringify('test') })
await $b24.placement.call('setValue', { value: JSON.stringify({ id: 1 }) })
setValue
async setValue(value: unknown): Promise<any>
Convenience wrapper around placement.call('setValue', ...) that performs
JSON.stringify on the value for you. Accepts any JSON-serializable value
(string, number, boolean, object, array).
$b24 = await initializeB24Frame()
// ... /////
await $b24.placement.setValue('test')
await $b24.placement.setValue({ id: 1, title: 'demo' })
callCustomBind
async callCustomBind(
command: string,
parameters: null | string | Record<string, any>,
callBack: (...args: any[]) => void
): Promise<any>
Calls an interface command and registers a callback that receives subsequent events from the command. Use this for commands that emit ongoing events (e.g. progress updates) instead of resolving once.
parameters accepts three shapes:
null— no payload.string— sent assingleOption.Record<string, any>— spread into the message payload.
$b24 = await initializeB24Frame()
// ... /////
$b24.placement.callCustomBind('subscribe', { topic: 'crm:deal' }, (event) => {
console.log('event', event)
})
Parent
Provides methods for managing the parent application window in Bitrix24, including resizing the window, managing scroll, initiating calls, and opening the messenger.
Slider
Provides methods for working with sliders in the Bitrix24 application. It allows opening and closing sliders, as well as managing their content.