Skip Navigation

[Resolved] call jquery after cred-delete-post

This support ticket is created 2 years, 8 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 28 replies, has 2 voices.

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

Assisted by: Christopher Amirian.

Author
Posts
#2337143

a.R

Hi, how do that?

I would like to .hide() the post ("wunsch") after deleting it.

Thank you 🙂

#2338205

Christopher Amirian
Supporter

Languages: English (English )

Hi there,

The "cred-delete-post" shortcode reloads the page after deleting a post. Alternatively, you can provide the POST ID to load after deleting the post under the "onsuccess" attribute. For more information:

https://toolset.com/documentation/programmer-reference/forms/cred-shortcodes/#cred-delete-post

Now I am not sure what you want to achieve by adding a Javascript code. If you give me the link of the page and more description I might be able to understand.

Thank you.

#2343893

a.R

hidden link

I want a post to disappear from that list after deleting it.
The list, however, should stay.

Thank you 🙂

#2344375

Christopher Amirian
Supporter

Languages: English (English )

Hi there,

Unfortunately I have no access and it shows No Items Found.

Would you please add a few sample items there and also share the login information so tghat I can test and see what is going on?

You need to set the next reply as private.

Thanks.

#2345047

Christopher Amirian
Supporter

Languages: English (English )

Hi there,

I checked the page and it is working as expected without any need to add Javascript code.

So I clicked the Delete option (LÖSCHEN) and the page reloads and does not show the deleted content anymore.

I checked and deleted two posts and now the list shows one post:

hidden link

Everything wors as expected.

#2347297

a.R

Ok - but is it possible WITHOUT reloading the page?
As reloading would be VERY misleading if someone had say 20 or 30 posts in that list...

And .hide() would be so easy,,,

#2348409

Christopher Amirian
Supporter

Languages: English (English )

Hi there,

I see what you mean now. Thre is no option for that as the Do Nothing option for the delete link will remove the post in the backend and there is no reference to be able to detect which post is deleted.

The best way is to implement the feature other way around.

Please kindly read this answer to know what to do and set to add the delete feature and do the post deleting by custom code:

https://toolset.com/forums/topic/delete-post-link-with-no-reference-to-wp-admin/#post-1342577

Thanks

#2349511

a.R

Done all that, nothing happens.

This is SO bad - isn´t it a BASIC function to delete a post?

#2349623

Christopher Amirian
Supporter

Languages: English (English )

Hi there,

The Delete functionality is available with the page load and not the Ajax form. You are welcomed to ask for a feature request for that option:

https://toolset.com/home/contact-us/suggest-a-new-feature-for-toolset/

As for the workaround that I mentioned, I'd be happy to check and see how you implemented it.

I'd appreciate it if you could give me the URL/User/Pass of your WordPress dashboard after you make sure that you have a backup of your website.
It is absolutely important that you give us a guarantee that you have a backup so if something happens you will have a point of restore.

Make sure you set the next reply as private and give me the link to the form that you created and the link to the content template and the view.

Thanks

#2350657

Christopher Amirian
Supporter

Languages: English (English )

Hi there,

I checked and there were two issues:

1. You set the form to New content instead of the Existing Content. I fixed that.

2. Also, you added the code to a plugin called Snippets. To be on the safe side I added to the Toolset Custome code:

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

Now that the system is working by the post form, it is possible to use the jQuery Hide on the form submit. That is why I added the Javascript code below to the JS Editor of the Meine Wunsche view:

jQuery(document).ready(function($) {
	$('form[id^="cred_form_4485"]').on('submit', function() {
	    $(this).closest('.archiveintrag').hide();
	});
});

Now if you check the listing it hides the post and also removes using the method mentioned in the previous reply.

Thanks.

#2351653

a.R

Thank you, Christopher.

This DID work once, but now it doesn´t anymore.
Did you change anything again lately?

#2351729

Christopher Amirian
Supporter

Languages: English (English )

Hi there,

I did not change anything in the code. I tested it again and it is working correctly for me.

Here is a video that I recorded:

hidden link

Thanks

#2351861

a.R

Ok, this really seems to work now.
I´m really sorry if I was wrong there.

Glad you put that jQuery in the post template, not in the view.

THANK YOU, CHRISTOPHER - great work!

#2351877

a.R

Still one problem: How make .hide() work in the VIEW 4029 too?

  jQuery(document).on('js_event_wpv_pagination_completed', function(event, data) {
	$('form[id^="cred_form_4485"]').on('submit', function() {
	    $(this).closest('.archiveintrag').hide(1500);
	});
  });

    jQuery( document ).on( 'js_event_wpv_parametric_search_form_updated', function( event, data ) {
	$('form[id^="cred_form_4485"]').on('submit', function() {
	    $(this).closest('.archiveintrag').hide(1500);
	});
	
});

doesn´t work.

THANK YOU

#2352765

a.R

That is in hidden link