Skip Navigation

[Resolved] Flipbooks not saving correctly due to js error

This support ticket is created 2 years, 5 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

This topic contains 10 replies, has 2 voices.

Last updated by Christopher Amirian 2 years, 5 months ago.

Assisted by: Christopher Amirian.

Author
Posts
#2449955

I am trying to: Save a flipbook but it doesn't save properly.

Link to a page where the issue can be seen:

I expected to see:

Instead, I got:

We asked the developer of Real3D flipbook and they came back with this message:

----------------------
I found that this script

hidden link

is causing the error when saving the flipbook, so flipbook is not saved properly and each flipbook that is saved will not work anymore.

It is running this function on each form submit, and this function is throwing an error


var onSubmit = function( e, formElement ) {
// Had to remove "e.preventDefault();" from here, since it was triggering a "confirmUnload" message
// in the browser through some TinyMCE dark magic.

// Make sure all TinyMCE editors are saved before we grab the values from their underlying textareas.
// This should address the race condition on the "submit" event.
if ( 'undefined' !== typeof( window.tinyMCE ) ) {
window.tinyMCE.triggerSave();
}

// Another adjustment: Survive forms that are identified only by a class name and make sure everything
// keeps working even if there are multiple forms with submitanyway on the same page.
var id = !! formElement ? formElement.id : this.id;
var className = !! formElement ? formElement.className : this.className;
var formSelector = !! id ? '#' + id : '.' + className;

cleanup( formSelector );

//get values of form elements with data-submitanyway attributes
//and add them to form
var params = merge( $( formSelector + " [data-submitanyway]" ), formSelector );
//console.log("params=", params);
if ( params != null && params.length > 0 ) {
$.each( params, function ( i, param ) {
// console.log("adding x-temp: name=" + param.name + ", value=" + param.value);
$( '<input />' ).attr( 'type', 'hidden' )
.attr( 'name', param.name )
.attr( 'value', param.value )
.attr( 'x-submitanyway-temp', "" )
.appendTo( formSelector );
} );
}
};

Please try to disable this "types" plugin, save flipbook that does not work, then enable this plugin again.

-------------------

If we disable types, resave the flipbooks and then enable it again, it works.

Can you help?

#2450493

Christopher Amirian
Supporter

Languages: English (English )

Hi there,

We are not familiar with the plugin in question and it needs to be tested to see where is the conflict with the mentioned code.

There is no guarantee but we can ask our second-tier support to take a look into the issue if it is possible to replicate the issue on a clean installation.

I created a WordPress installation with Toolset plugins installed and you can access the dashboard here:

hidden link

Please install the plugin there and replicate the issue and get back to us with the page with the problem and we will report this.

Thanks.

#2452165

Hi,

We installed the flipbook plugin and tried to replicate it but didn't get very far.
The website with the issue is very complex and it could even be a combination of plugins causing the issue and difficult to replicate.

We do know that disabling types, resaving the flipbook and re-enabling types gets around the issue.

If you're OK with it (and you're careful), we can give you access to the live website (like we did for the flipbook developer) to have a look at it?

#2452305

Christopher Amirian
Supporter

Languages: English (English )

Hi there,

As you could not replicate the issue on a clean installation there is no guarantee that we can help here. We will do our best to check.

We can not check the website on a live website it is tricky.

Please use either the duplicator plugin or the all-in-one migration plugin and upload the files to a file sharing service and share the link with us in the next reply.

For more information:

https://toolset.com/faq/provide-supporters-copy-site/

Please make sure that you will set the next reply as private.

Thanks.

#2452409

Hi,

Unfortunately, the website is WAY too large to use with those plugins so we'll have to clear a clone of it and give you access.

Hopefully, this is OK for you.

#2452739

Christopher Amirian
Supporter

Languages: English (English )

Hi there,

Yes I think that would work too.

Please make sure that you set the next reply as private to provide the clone login info and we will check to see if we can get a clue.

Thanks.

#2452741

Christopher Amirian
Supporter

Languages: English (English )

Hi there,

Yes I think that would work too.

Please make sure that you set the next reply as private to provide the clone login info and we will check to see if we can get a clue.

Thanks.

#2452993
#2454777

Christopher Amirian
Supporter

Languages: English (English )

Hi there,

I entered your website and could not find a clue till now.

The only thing that I see which is different is that you used an older version of the Flipbook on the clean installation.

Would you please install version 3.37.3 here:

hidden link

Or alternatively, downgrade Flipbook to version 3.36 and see if it works.

Thanks.

#2455223

Hi,

We've installed 3.37.3 on this sandbox and can now recreate the issue.
When a flipbook is saved/updated, it now doesn't show on the procession.

I'm checking with the flipbook developer as 3.36 is the "official" one that can be downloaded. I assume 3.37.3 comes from their repo directly as an update.

Hope this helps.

#2455567

Christopher Amirian
Supporter

Languages: English (English )

Hi there,

I will ask the dev team to see if they can find a clue about the issue. But the fact that a version of the plugin works with Toolset and another version does not while using the same Toolset version, shows that there is a change on their codebase that causes the issue.

We will report this to the dev team but please consider that there is no guarantee for a fix as we do not claim that Toolset is compatible with that plugin.

As a worst-case scenario, you are welcome to use an older version of the Flipbook plugin or turn off Types whenever you need to edit a flipbook.

Thanks.

#2457053

Christopher Amirian
Supporter

Languages: English (English )

Hi there,

We have a workaround that you can apply. We tested that on the clean installation and it worked.

The basic idea is that the Javascript file is not needed for that page. So we prevent that Javascript file to load for that page.

Please follow the steps below to add custom code to Toolset:

https://toolset.com/documentation/programmer-reference/adding-custom-code/using-toolset-to-add-custom-code

And there, add the code below:

toolset_snippet_security_check() or die( 'Direct access is not allowed' );

/**

Dequeue Types scripts which conflict with Real3D Flipbook

*/

add_action( 'admin_enqueue_scripts', 'ts_types_compat', PHP_INT_MAX, 1 );
function ts_types_compat( $hook ){

	if ( 'post.php' == $hook || 'post-new.php' == $hook ) {
		$screen = get_current_screen();

		if ( isset($screen->post_type) && $screen->post_type == 'r3d' ) {

			wp_dequeue_script( 'types-post-add-or-edit-no-components' );
			wp_dequeue_script( 'types-submit-anyway' );
		}
	}
}

Thanks.