A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://docs.telerik.com/aspnet-mvc/html-helpers/editors/editor/immutable below:

ASP.NET MVC Editors Editor Immutable Elements

New to Telerik UI for ASP.NET MVC? Start a free 30-day trial Immutable Elements

The immutable feature enables you to add HTML elements that cannot be edited by the user.

For a runnable example, refer to the demo on immutable elements in the Editor.

Enabling Immutable Elements

To define the immutable elements in the content area, set the contenteditable DOM attribute to false. To prevent the user interaction with that element, you also need to enable the Immutables() configuration method.

    @(Html.Kendo().Editor()
        .Name("editor")
        .Immutables(true)
        .Value("<div contenteditable='false'>this is immutable</div><div>this is mutable</div>")
    )
Serializing Immutables

The Serialization() method enables you to control the HTML representation of the immutable elements in the viewHtml dialog.

The immutables.serialization configuration method accepts the following parameters:

Deserializing Immutables

The Deserialization() method does the opposite of the Serialization() one. Deserialization() takes the HTML representation from the ViewHtml dialog and alters the immutable DOM element based on the implemented logic in the callback function.

The following example demonstrates how to use the Serialization() and Deserialization() options to expose the CSS text-align property in the ViewHtml dialog so that the user is able to change it from the HTML code.

    @(Html.Kendo().Editor()
        .Name("editor")
        .Immutables(i => i
            .Serialization("<immutable style='# if(data.style.textAlign){#text-align: #=data.style.textAlign##}#'></immutable>")
            .Deserialization("immutablesDeserializationHandler")
        )
        .Value("<div contenteditable='false'>this is immutable</div><div>this is mutable</div>")
    )
    <script>
        function immutablesDeserializationHandler(node, immutable) {
            immutable.style.textAlign = node.style.textAlign;
        }
    </script>
Applying a Default Decoration

To decorate all contenteditable="false" elements and improve user experience (UX), use a CSS rule.

    <style>
        .k-editor [contenteditable='false']{
            opacity: 0.5;
        }
    </style>

    @(Html.Kendo().Editor()
        .Name("editor")
        .Tag("div")
        .Immutables(true)
        .Value("<div contenteditable='false'>this is immutable</div><div>this is mutable</div>")
    )
See Also

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4