yakovlevga / brickyeditor

WYSIWYG block editor jQuery plugin.
MIT License
115 stars 20 forks source link

Error when init with blocksUrl #44

Open nqtuyen opened 4 years ago

nqtuyen commented 4 years ago

pls help me. Thanks!

jquery.brickyeditor.js:426 Uncaught (in promise) TypeError: blocks.forEach is not a function at Editor.loadBlocks (jquery.brickyeditor.js:426) at Editor. (jquery.brickyeditor.js:335) at step (jquery.brickyeditor.js:31) at Object.next (jquery.brickyeditor.js:12) at fulfilled (jquery.brickyeditor.js:3)

yakovlevga commented 4 years ago

Hi, could you, please, provide the config you use during plugin initialization.

nqtuyen commented 4 years ago

Hi, this is my config. pls give me your solutions, thank you so much! I use it in ASP.NET MVC projects. I store datajson to db and reload when edit.

$("#editor").brickyeditor({ templatesUrl: "/design/templates/", blocksUrl: '/design/datajson/@Model.Id',

        onload: function (editor) {
            $("#renderHtmlBtn").on("click", function () {
                var html = editor.getHtml();
                $('#renderHtml').val(html);
            });
        },
        onChange: function (blocksJson, blocksHtml) {
            $('#renderHtml').val(JSON.stringify(blocksJson));
        }
    });