elementor icon indicating copy to clipboard operation
elementor copied to clipboard

elementor.saver.update and elementor.getPanelView().setPage doesn't work

Open wpsoul opened this issue 5 years ago • 11 comments

Previously, we used code to add custom settings in Page settings.

elementor.settings.page.addChangeCallback( 'content_type', function( newValue ) { elementor.saver.update( { onSuccess: function() { elementor.reloadPreview(); elementor.once( 'preview:loaded', function() { elementor.getPanelView().setPage( 'page_settings' ); } ); } } ); } );

This doesn't work now. Plugin has notice

update is soft deprecated since 2.9.0 - Use $e.run

But $e is not defined under hook elementor/frontend/init

elementor.getPanelView().setPage( 'page_settings' ) also doesn't work, plugin jump to general tabs in any case.

What is the correct code to make custom page settings?

wpsoul avatar Feb 19 '20 19:02 wpsoul

The same problem for me. '$e' is undefined when trying to use it from Elementor editor. It's defined in window console while being in Edit width Elementor mode though. But it doesn't help.

artkrsk avatar Feb 21 '20 11:02 artkrsk

Any updates on this?

artkrsk avatar Feb 28 '20 02:02 artkrsk

Try:

                elementor.saver.saveEditor({
                    status: elementor.settings.page.model.get('post_status'),
                    onSuccess: () => {

                    }
                })

This worked for me. Update is alias for saveEditor.

pmallek avatar Mar 27 '20 14:03 pmallek

Actually the problem is not in the updating function. I can't restore the opened panel. $e.route doesn't work because $e is undefined. The old method elementor.getPanelView().setPage( 'page_settings' ) doesn't work either. It leads in a poor UX when user has to re-open the panel manually each time after the saving.

artkrsk avatar Mar 27 '20 15:03 artkrsk

This worked for me. Update is alias for saveEditor.

saveEditor is working but it shows notice saveEditor is soft deprecated since 2.9.0 - Use $e.internal( 'document/save/save' ) instead

So, it's the same issue as early.

elementor.getPanelView().setPage( 'page_settings' ) also doesn't work as it should work.

wpsoul avatar Mar 28 '20 21:03 wpsoul

I am having a similar issue with the following code. Has anyone identified a working solution to convert this to using $e.hooks which is what is suggested.

jQuery( function( $ ) { elementor.saver.on( ‘after:save’, function( data ) { console.log( ‘Updated!’ ); } ); });

I tried using "elementor.saver.saveEditor({" and it no longer works because "elementor" is undefined. Is there a solution to this issue?

Has anyone found a work around for this?

@seshelby I found - just removed Elementor. Check other pages here, thousands of critical bugs and developers of Elementor don't care.

wpsoul avatar Oct 18 '20 20:10 wpsoul

Try enqueuing the JS file you run your $e code in using the action 'elementor/editor/after_enqueue_scripts'. $e is available once the editor scripts are loaded.

udidol avatar Dec 24 '20 09:12 udidol

I have used below code with current Elementor version and it is working:

jQuery(window).on('elementor:init', function(){
	elementor.settings.page.addChangeCallback('control_id_here', function(newValue){
		$e.run('document/save/update').then(function(){
			elementor.reloadPreview();
			elementor.once('preview:loaded', function(){
				 setTimeout(function(){
	 	 	 	 	 $e.route('panel/page-settings/settings');
	 	 	 	 }, 1);
			 });
            });
	});
});

Code needs to be enqueued using elementor/editor/before_enqueue_scripts action.

SewoSew avatar Oct 17 '24 09:10 SewoSew