Try our conversational search powered by Generative AI!

John-Philip Johansson
Jan 29, 2019
  5837
(6 votes)

One OPE attribute to rule them all: data-epi-edit (CMS UI 11.16.0)

In CMS UI 11.16.0, we're making it easier for everyone doing client-side rendered websites to mark up their HTML.

Before 11.16.0

In a previous post, I explained how to make an element editable in On-Page Edit when rendered by a client-side framework (e.g. React, Angular, Vue, etc). It was necessary to add three attributes:

<span data-epi-property-name="YourProperty" data-epi-property-render="none" data-epi-property-edittype="floating">{your JS framework decides how the value is actually rendered}</span>

This is slightly verbose. Although you could wrap it in some helper method in your JavaScript framework of choice (like we did in the MusicFestival sample site), it would require less "magic" or less reading of our documentation if there was only one attribute for frontend developers to remember. That's why we're introducing data-epi-edit. It does not have any specific behavior to learn about. It's equivalent to setting the properties above, and setting any of those properties as well will simply be ignored.

With 11.16.0

It's now enough with one simple attribute:

<span data-epi-edit="YourProperty">{your JS framework decides how the value is actually rendered}</span>

One note

We recommend that you don't render any data-epi-* attributes in View mode, as to not give too many details about the internal workings of your site. That's what @Html.PropertyFor() and @Html.EditAttributes() do when using Razor views. When taking over the rendering on the client-side, this responsibility moves over as well. One way is to use the global epi.beta.isEditable property (CMS UI 11.11.0, see blog or documentation) to toggle the rendering off and on, as we've done in MusicFestival (see here and here).

Learn more

Documentation: https://world.episerver.com/documentation/developer-guides/CMS/editing/on-page-editing-with-client-side-rendering/

MusicFestival has been updated to use this in the Vue directive v-epi-edit: https://github.com/episerver/musicfestival-vue-template/blob/129be15ae4a/src/MusicFestival.Vue.Template/Assets/Scripts/directives/epiEdit.js

Jan 29, 2019

Comments

Valina Eckley
Valina Eckley Jan 29, 2019 07:59 PM

Nice!  Great work JP!

Jake Jones
Jake Jones Mar 6, 2019 04:16 PM

Finally had a chance to check this out and it worked flawlessly. Nice job!

Please login to comment.
Latest blogs
Optimizely and the never-ending story of the missing globe!

I've worked with Optimizely CMS for 14 years, and there are two things I'm obsessed with: Link validation and the globe that keeps disappearing on...

Tomas Hensrud Gulla | Apr 18, 2024 | Syndicated blog

Visitor Groups Usage Report For Optimizely CMS 12

This add-on offers detailed information on how visitor groups are used and how effective they are within Optimizely CMS. Editors can monitor and...

Adnan Zameer | Apr 18, 2024 | Syndicated blog

Azure AI Language – Abstractive Summarisation in Optimizely CMS

In this article, I show how the abstraction summarisation feature provided by the Azure AI Language platform, can be used within Optimizely CMS to...

Anil Patel | Apr 18, 2024 | Syndicated blog

Fix your Search & Navigation (Find) indexing job, please

Once upon a time, a colleague asked me to look into a customer database with weird spikes in database log usage. (You might start to wonder why I a...

Quan Mai | Apr 17, 2024 | Syndicated blog

The A/A Test: What You Need to Know

Sure, we all know what an A/B test can do. But what is an A/A test? How is it different? With an A/B test, we know that we can take a webpage (our...

Lindsey Rogers | Apr 15, 2024

.Net Core Timezone ID's Windows vs Linux

Hey all, First post here and I would like to talk about Timezone ID's and How Windows and Linux systems use different IDs. We currently run a .NET...

sheider | Apr 15, 2024