Skip Navigation

[Resolved] Remove relationshit with ajax (cred-delete-relationship)

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.

Sun Mon Tue Wed Thu Fri Sat
9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 - - 9:00 – 13:00
14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 - - 14:00 – 18:00

Supporter timezone: Africa/Casablanca (GMT+01:00)

This topic contains 1 reply, has 2 voices.

Last updated by Jamal 2 years, 5 months ago.

Assisted by: Jamal.

Author
Posts
#2213655

I use the following view with to show and remove a connection between two posts:

<div class="row" id="connected-[wpv-post-id]">
  <div class="col-md-10 col-sm-10 col-xs-10" style="position: relative;">   
       <span class="actions">#[wpv-post-id] - [wpv-post-title]</span>
  </div>
  <div class="col-md-2 col-sm-2 col-xs-2">   
    [cred-delete-relationship role_items='$fromViews' relationship='profil-nfc-chip' redirect='self' class='disconnect']<span class="dashicons dashicons-remove" title="Entfernen"></span>[/cred-delete-relationship]
  </div>
</div>

Nonetheless, I would prefer this to happen via ajax. It want an ajax function that removes the line with the id "connected-[wpv-post-id]" after processing the disconnection. It would work like this example.

		jQuery('.disconnect').click(function() {
			//replace remove-icon with loading animation
			jQuery(this).html('<div class="lds-dual-ring dark"></div>');

			//if Ajax succes: get the ID of the clicked element and delete the row
			//var id = jQuery(this).attr('data-relateditemtwo');
			//jQuery("#connected-"+id).remove();
			//endif
		});

But unfortunately, adding this jQuery breaks the functionality of the cred-delete-relationship shortcode. It shows the loader but not even the page refresh happens. Also, I would need the second part to only fire after the disconnection is processed. Any idea?

EDIT: Can s.o. please correct my title, there is a not so nice typo...

#2215167

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+01:00)

Hello and thank you for contacting the Toolset support.

This Toolset shortcode does not support AJAX calls, it will always reload the page, or redirect to a different page. If you believe this should support AJAX, please suggest it here https://toolset.com/home/contact-us/suggest-a-new-feature-for-toolset/

If you want to implement this with AJAX, you will have to create your own AJAX action and handler and call it with Javascript code. Check these articles:
- hidden link
- hidden link

You can use the toolset_disconnect_posts function from our Relationship API https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_disconnect_posts

I hope this answers your request. Let me know if you have any questions.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.