grapesjs icon indicating copy to clipboard operation
grapesjs copied to clipboard

Could some one please help me with Custom Load.

Open rajatkumcom opened this issue 8 years ago • 4 comments

What I can use instead of followings-

editor.setHtml( arr_data['html'] ), editor.setCss( arr_data['css'] ),

In below code.

rajatkumcom avatar Feb 28 '18 11:02 rajatkumcom

Below is my code:-

editor.Commands.add( 'load-command', {
        run(editor, sender) {

            editor.load(() => {
                sender.set('active', 0);
            });

    		var arr_html_data = {};

    		arr_html_data['nid'] = 65;
    		arr_html_data['content_type'] = "";
    		arr_html_data['op'] = "loadContent";

            $.ajax({
    			url: DrupalBasePath + '/landing/joperation/1',
    			method: "POST",
    			data: JSON.stringify( {
    				'op' : "loadContent",
    				'request': arr_html_data,
    			} ),
    			dataType: "json"
    		}).done(function( data ) {
    		    alert( "Data has been loaded successfully." );
    		    var arr = $.map(data, function(el) { return el });
    		    var arr_data = JSON.parse( arr[0]['data'] );
    		    console.log( editor );
    		    editor.setHtml( arr_data['html'] ),
				editor.setCss( arr_data['css'] ),
//				arr_data['assets'] = editor..getAll();
				editor.setStyle( arr_data['style'] ),
				editor.setComponents( arr_data['components'] );
    		    
    		});
        },
    },
);

What I can use insted of followings- editor.setHtml( arr_data['html'] ), editor.setCss( arr_data['css'] ),

Thanks in Advance.

rajatkumcom avatar Feb 28 '18 11:02 rajatkumcom

Just don't use them for loading your template data

editor.setStyle( arr_data['style'] ),
editor.setComponents( arr_data['components'] );

is all what you need

artf avatar Mar 02 '18 00:03 artf

Thank you....

rajatkumcom avatar Mar 02 '18 05:03 rajatkumcom

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.

lock[bot] avatar Sep 17 '19 22:09 lock[bot]