GrapesJS / grapesjs

Free and Open source Web Builder Framework. Next generation tool for building templates without coding
https://grapesjs.com
BSD 3-Clause "New" or "Revised" License
22.4k stars 4.06k forks source link

remote storage load-method fired twice on-load #155

Closed derblub closed 7 years ago

derblub commented 7 years ago

I've encountered a small issue, where the initial data is being loaded twice on init (when autoload: true is set).
My config:

lp.builder = grapesjs.init({
    clearOnRender: true,
    plugins: ['gjs-preset-newsletter'],
    pluginsOpts: {
        'gjs-preset-newsletter': {
            '...':'...'
        }
    },
    assetManager: {
        storeOnChange: true,
        storeAfterUpload: true,
        upload: 'upload_assets/',
        beforeSend: lp.addCsrfTokenHeader
    },
    storageManager: {
        id: '',
        type: 'remote',
        autosave: true,
        autoload: true,
        stepsBeforeSave: 5,
        storeComponents: false,
        storeStyles: false,
        storeHtml: true,
        storeCss: true,
        urlStore: 'save/',
        urlLoad: 'load/',
        beforeSend: lp.addCsrfTokenHeader,
        onComplete: lp.resetSaveButton
    }
});

When I try to listen to 'storage:load'-event from editor, nothing is being logged, but Chrome's network-tab shows 2 xhr-requests to urlLoad endpoint.

artf commented 7 years ago

Will check for the loader. About the listeners, some events are called at render so you have to put those listeners before the call (you have to use autoload: false)

artf commented 7 years ago

should be fixed in https://github.com/artf/grapesjs/releases/tag/v0.10.2

cmcintosh commented 7 years ago

@artf the thing I have noticed is that when you run .store() or .load() i am not seeing ajax calls out to the provided urls. My worklow instead is to have a $.ajax call inside of the store/load functions.

artf commented 7 years ago

Hi @cmcintosh sounds like you've missed something in config, if you want you can open a new issue with some detail about it

lock[bot] commented 5 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.