Giter Site home page Giter Site logo

Comments (16)

bradmac avatar bradmac commented on July 25, 2024 2

Here's what we do in Kademi

    btnSaveFile.on('click', function (e) {
        e.preventDefault();

        showLoadingIcon();
        var fileContent = $('#content-area').keditor('getContent');
        var saveUrl = postMessageData && postMessageData.pageName ? postMessageData.pageName : fileName;

        $.ajax({
            url: saveUrl,
            type: 'POST',
            data: {
                body: fileContent
            },            
            dataType: 'json',
            success: function () {
                if (isEmbeddedIframe) {
                    doPostMessage({
                        isSaved: true,
                        resp: postMessageData.resp,
                        willClose: postMessageData.willClose
                    }, postMessageData.url);
                } else {
                    Msg.success('File is saved!');
                }

                hideLoadingIcon();
                body.removeClass('content-changed');
            },
            error: function (e) {
                Msg.error(e.status + ': ' + e.statusText);
                hideLoadingIcon();
            }
        })
    });

from keditor.

bradmac avatar bradmac commented on July 25, 2024 1

@umefarooq note that logging uses a function which checks to see if the console is enabled, so it is safe to leave logging enabled in production.

from keditor.

umefarooq avatar umefarooq commented on July 25, 2024

so quick let me try if its work really thanks.

from keditor.

umefarooq avatar umefarooq commented on July 25, 2024

it worked amazing, now part of my development list, how can i disable all console logs.

from keditor.

anhnt avatar anhnt commented on July 25, 2024

@umefarooq can you create an issue for it? I would assume that it should be an option like
$('div').keditor({debug: false});

from keditor.

ducdhm avatar ducdhm commented on July 25, 2024

@umefarooq: If you want, you still can disable log console by using this code $.keditor.debug = false;

from keditor.

 avatar commented on July 25, 2024

Amazing plugin.
@ducdhm @bradmac can you please tell me if I can again load the page design after saving html through this line of code?

var fileContent = $('#keditor-body').keditor('getContent');

from keditor.

bradmac avatar bradmac commented on July 25, 2024

Hey @umarch06 what do you mean by loading the page design again? In Kademi we save the content with ajax and the user just continues editing, so the page is not reloaded.

from keditor.

 avatar commented on July 25, 2024

@bradmac consider that I need to save a page and then I have to reload it with the same design I left with.
Like in an invoice, a person may have as much design as he want and later on he needs to build a new invoice with some of his custom designs?

from keditor.

bradmac avatar bradmac commented on July 25, 2024

OK, so it sounds like what you want is to save to a template library, and allow your users to load from that template library, right?

You can definitely do that, but i would expect thats outside of the scope of keditor. You would want to create a new table in your db, create an ajax service to get and set templates, and then have some sort of drop down to select one which would load the content into the content editor

from keditor.

 avatar commented on July 25, 2024

yes exactly @bradmac you got me right.
I need to save templates. Later on I need to use them again, even again I can have right to make changes in that.
The question is relative. Like thorugh this code var fileContent = $('#keditor-body').keditor('getContent');
I am gonna get all the html. Later on I will save it to db and then again I will reload it on my page.
Problem is that, how will I render that again? How would all the stuff be created again, like containers, snippets and anything else. Please refer to this --url--
How would be everything get back to that state which I was before saving and reloading (like elements on invoice page, the draggers and each and evey property like drag, settings etc would be needed to remain same after reloading)?
I have created a new tab that names Invoice Items. Keep in mind that it was not created by using ExtraTabs in your plugin. I myself created it through some custom logic. Since it needs to be dynamic.

Note that I will remove this url which I provided above after your comment.

from keditor.

bradmac avatar bradmac commented on July 25, 2024

We generate editor page like this (uses velocity):

<div id="content-area">$!file.body</div>

And then we initialise it like this:

    contentArea.keditor({
        ckeditorOptions: {
            skin: editorSkin,
...

To load new content we would simple replace the content div and then re-init keditor

$("#content-area").html(newContent);
contentArea.keditor({..});

The content produced by keditor should be clean, it should not contain anything editor specific such as draggers.

from keditor.

bradmac avatar bradmac commented on July 25, 2024

BTW, you should really consider using dynamic components. Check it out here, but you might want to skip my long boring intro and skip forward to about 4:30 :)

http://www.kademi.co/blogs/kb/building-customized-analytics-dashboards/

from keditor.

 avatar commented on July 25, 2024

@bradmac I loved the way you have implemented this. I watched your video till the end and wonder why in that case Elements and Containers are on same tab and some other snippets are separately placed on second tab of side bar.

  • Moreover, it would have been excellent if one could drag elements on content area rather than first placing containers and then placing elements in those containers (most of us need to drag single element) to some custom space.
  • I would also need to suggest you a thing that the containers should be move able in their parent content areas like I did in the (deleted)URL I provided above. Resizing is a plus too. The reason I am asking for so is that almost every drag and drop I have seen on internet restricts user to push the containers in stack (containers are not free to move or in simple words I can say I cannot place the element exactly at that position that I wish).
  • Coming to dynamic content, what If I need the things to come from some webservices like in my case and than show them in side bar. Since I can see the html has been restricted to show the elements only if they are present in dyamic_content file.

from keditor.

Dhara-ZYMR avatar Dhara-ZYMR commented on July 25, 2024

Hi @ghost
I like to do a similar thing.. Can you please share your code which you have done.
It would be much appreciated!

@bradmac Any way to get snippets and its data dynamically?

from keditor.

ducdhm avatar ducdhm commented on July 25, 2024

@Dhara-ZYMR You can check my comment in this issue to know the ways to load dynamic components' content: #76 (comment)

from keditor.

Related Issues (20)

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.