Git Product home page Git Product logo

editablemvc's Introduction

EditableMvc

The package provides persistent inline page editing using CKEditor.

For a quick overview of the library installation and use check the youtube video.

###How it works: The EditableMvc helper will render the specified selected html element and enable the inline editing functionality of CKEditor. Once edited, the content is posted via ajax to a controller action and the data get saved through a repository layer, which can be easily swapped (default storage is xml serialization on filesystem).

###Setup: Firstly download the package using NuGet

PM> Install-Package EditableMvc

The default configuration deployed with the package enable the edit functionality when editablemvc=true is present in the querystring and setup the repository to use files.

public static class EditableMvcBootstrap
{
    public static void Start()
    {
        //Register a custom repository by implementing IEditableRepository 
        EditableMvcConfig.RegisterRepository = () => new SimpleFileRepository("~/App_Data");

        //Register the authorization method used to enable/disable editing on the html element
        EditableMvcConfig.RegisterAuthorization = () =>
        {
            var editable = !string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["editablemvc"]);
            if (editable)
            {
                return Convert.ToBoolean(HttpContext.Current.Request.QueryString["editablemvc"]);
            }
            return false;
        };
    }
    
    //After App_Start is executed register the bundles
    public static void PostStart()
    {
        BundleTable.Bundles.Add(new ScriptBundle("~/bundles/editableMvc").Include(
        "~/Scripts/jquery-ui-{version}.js",
        "~/Scripts/ckeditor/ckeditor.js",
        "~/Scripts/ckeditor/plugins/editablemvcsave/editablemvcsave.js",
        "~/Scripts/editablemvc.js"));
    }
}

###Use it: Ensure all the required js (and optional style) are registered

@Scripts.Render("~/bundles/editablemvc")
@Styles.Render("~/Content/editablemvcstyle.css")

Now that everything is in place, let's try the helper and generate an editable paragraph with some default text

<div id="content">
    @Html.EditableMvc("p", "idParagraph", new {@class = "mycssclass", "<strong>Lorem ipsum...</strong>")
</div>    

editablemvc's People

Contributors

george2giga avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.