Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to loadDesign from mySQL? #79

Open
mprince2k18 opened this issue Mar 18, 2021 · 0 comments
Open

How to loadDesign from mySQL? #79

mprince2k18 opened this issue Mar 18, 2021 · 0 comments

Comments

@mprince2k18
Copy link

I am using unlayer editor in my laravel project. I want to load my existing HTML markup into the editor. But it's not working with loadDesign and loadTemplate function. Here is my code.

<script>

class EmailEditor {
    constructor(id) {
        unlayer.init({
        id: id,
        displayMode: "web",
        appearance: {
            theme: 'dark',
        }
        });
    }

    loadDesign(design) {
        unlayer.loadDesign(design);
    }

    saveDesign(callback) {
        unlayer.saveDesign(callback);
    }
    exportHtml(callback) {
        unlayer.exportHtml(callback);
    }
}

    const editor = new EmailEditor('editor-container');

    const saveHTMLBtn = document.getElementById('update_html_btn');

    saveHTMLBtn.addEventListener('click',e => {
    editor.exportHtml(
        d => {
            // Ajax

            var body = d.html;

            $.post('{{ route('api.page.content.create') }}', 
            {_token:'{{ csrf_token() }}', 
            page_id: '{{ $content->id }}', 
            title: '{{ $content->title }}',
            body: body
        },  
            function(data){
                console.log(data);
            });

          }
        );
    });

</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant