- Build
- References
Visual Editor Events
Technical reference for client-side events that Stackbit emits to customize how your site reloads content.
Event Response
When event listener functions fire, they are passed an event object argument with a detail
property.
This detail property will contain context for the current editing environment (more on context below), along with custom properties related to the specific event.
1
2
3
Event Context
The event.detail
object contains contextual properties that are consistent among all events. These properties are detailed in the Context
type below.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Example:
Here's an example of an expected shape for the base-level context object, available as event.detail
in an event listener callback. Additional custom properties are documented below.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Event Listeners
Stackbit fires the events below based on the various triggers from actions taken by content editors in the Stackbit application.
stackbitObjectsChanged
Fires when content changed. This event is typically used to override the default automatic content reload behavior.
Usage:
1
2
3
event.preventDefault()
in your callback code - just like you would with standard DOM events.
Event Detail:
1
2
3
4
5
6
7
8
stackbitLocaleChanged
Fires when an editor changes the current locale using the locale switcher.
Usage:
1
2
3
4
Event Detail:
1
2
3
4
Visual Editor Actions
A stackbit
object is attached to the window and contains function properties that can be used to customize the visual editing experience.
setLocale
Switches the current locale. The updated locale will be reflected in the locale switcher.
Usage:
1
Parameters: