Area: Optimizely CMS
Applies to versions: 11.24.0 and higher

On-page editing with client-side rendering

Recommended reading 

Optimizely offers some features to make client-side rendering easier. These features are framework agnostic, so they can be used with any JavaScript framework, such as Angular, React, or Vue.

Editing HTML attributes

CMS UI includes three HTML attributes that can be added to editable DOM elements:

  • data-epi-property-name="YourProperty"
    This attribute marks an element for editing.
  • data-epi-property-render="none"
    This attribute prevents the DOM from being modified directly when editing. Using data-epi-property-edittype="inline" overrides this and will modify the DOM (note, "inline" is the default for string properties).
  • data-epi-property-edittype="floating"
    This attribute creates a dialog for editing, and should be used for string types.

From CMS UI 11.16.0, it is enough with one HTML attribute:

  • data-epi-edit="YourProperty"

Editing HTML attributes for blocks

Editable blocks rendered in a content area should have this HTML attribute on each block element:

  • data-epi-block-id="ContentLinkID"
    This attribute marks a block element for editing.


To know when to re-render, subscribe to the topic contentSaved. The controller must contain the attribute [RequireClientResources] unless it inherits from either PageController or ContentController, as these both include the attribute by default. The resources then need to be required in a razor view with other scripts for the site using @Html.RequiredClientResources("Footer").

Handling context modes

In order to properly apply edit overlays and enable/disable client-side routing as needed, the client requires some sort of indicator of the current context mode. For this purpose, Optimizely provides the following properties in the epi object :

  • inEditMode
    True in both edit mode and preview mode
  • isEditable
    True in edit mode and false in preview mode
  • ready
    True if the property isEditable has been initialized. Otherwise, subscribe to epiReady to get those properties as soon as they are available

Navigation in on-page edit

In order to update the editing context (page tree, for this page folders and so on) when navigating the site by clicking links in the preview iframe there are two requirements. The links needs to be actual hyperlinks with an <a> tag and the href attribute needs to be an "edit mode" URL. Details can be found in this blog post on routing.

Content delivery API

Optimizely has released a content delivery API to make a headless implementation even easier. Check out the documentation.

SPA template site (New in CMS UI 11.11.0)

To demonstrate some useful concepts when creating a Single Page Application with working on-page editing, see the MusicFestical SPA template site on Github. For descriptions of the template site, see the blog post Introducing a new SPA template site: MusicFestival.

Related topics

Recommended blog series

  1. Introducing a new SPA template site: MusicFestival
  2. Routing in a SPA with a working On-Page Editing experience (CMS UI 11.11.0)
  3. Tips and tricks for a great On-Page Editing experience in SPAs and other client side rendered sites
  4. Represent the concept of "pages" and "blocks" with matching client side components in a SPA

Blog posts

Do you find this information helpful? Please log in to provide feedback.

Last updated: Jan 29, 2019

Recommended reading