elementor.saver.update and elementor.getPanelView().setPage doesn't work
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?
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.
Any updates on this?
Try:
elementor.saver.saveEditor({
status: elementor.settings.page.model.get('post_status'),
onSuccess: () => {
}
})
This worked for me. Update is alias for saveEditor.
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.
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.
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.
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.
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.