Skip Navigation

[Resolved] What is the difference between Clear Value and Replace Image Buttons?

This support ticket is created 4 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.

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 9 replies, has 2 voices.

Last updated by Robert 4 years, 8 months ago.

Assisted by: Jamal.

Author
Posts
#1624499
image.png

Tell us what you are trying to do? I am trying to understand why there are 3 different buttons when it comes to a Repeatable image custom fields. From the attached photo, I see a trash icon, a clear value "x" icon, and a "Replace Image" button.

What is the difference in all these buttons and why do we need them?

#1624563

Hello and thank you for contacting the Toolset support.

Clear, and reorder icons are required to let you manage the repeatable field.

Replace image is useful for keeping the same order. Otherwise, you will remove, add, then drag/drop the image to the old image position.

With some custom CSS styles, you can remove/hide any of these icons.

I hope this answers your question. Please, let me know your feedback.

#1624629

so "x" is clear, "4 arrows" is reorder, and the "Replace Image" button is a button, but what is the difference between the "Trash can" (which I assume is delete) and "x"?

#1624639

Right, my apologies for missing that. That might be redundant, but it might also be helpful for some designing scenarios.

If you have trouble removing/hiding any of them, please let me know which page and I can take a look at it and help produce a CSS code that will hide them.

If on the other side, you think this should be fixed in Toolset, or maybe adding an option for it on the settings, please ask it here http://toolset.com/contact-us/suggest-a-new-feature-for-toolset/

#1624863

So I can hide the Add button from the previous JS you gave me (js-wpt-repadd), but I can seem to unhide the Add button when the trash icon is clicked. In fact my alert isn't even called. It looks like trash uses js-wpt-repdelete. Am I missing something?

jQuery(function($) {
$(".listing-limit .js-wpt-repadd").click(function(event) {
$length = this.parentNode.childNodes.length;
var remaining = $('[name="wpcf-listing-images-remaining"]').val();
remaining--;
$('[name="wpcf-listing-images-remaining"]').val(remaining);
if ($length >= 5) {
$(this).hide();
}
});
});

jQuery(function($) {
$(".listing-limit .js-wpt-repdelete").click(function(event) {
alert("TEST");
var remaining = $('[name="wpcf-listing-images-remaining"]').val();
remaining++;
$('js-wpt-repadd').show();
$('[name="wpcf-listing-images-remaining"]').val(remaining);
});
});

#1624937

So I think I have it resolved for that part. It looks like I need a listener event instead of a click:

// add click listener to trash buttons
jQuery(document).on( "mouseup", ".js-wpt-repdelete", function(e){
var $closest = jQuery(e.target).closest('.js-wpt-repetitive');
var remaining = $('[name="wpcf-listing-images-remaining"]').val();
$closest.find(".js-wpt-repadd").show();
remaining++;
});

Keeping this open a little longer as i finish this out.

#1625083

Okay I have most of it figured out except how to hide the "X" icon and the "Replace Image" button. Can you help with that part?
Here is my Jquery:

jQuery(window).bind("load", function(){
var $listType = jQuery('select[name=wpcf-list-type]').val();

var $max;

// alert("listtype: " + $listType);
if ($listType == 'standard'){
jQuery(".js-wpt-repadd").hide();
}
else if ($listType == 'premium') {
$max = '5';
}
else if ($listType == 'featured') {
$max = '10';
}

jQuery(document).on( "click", ".js-wpt-repadd", function(e){
var $closest = jQuery(this).closest('.js-wpt-repetitive');
var isfile = $closest.find('input[type="file"]').length;
var name = isfile ? $closest.find('.wpt-repetitive-field:first input[type="file"]:first').attr('data-wpt-name') : $closest.find('.wpt-repetitive-field:first input:first').attr('data-wpt-name');

// how many repetitions?
if ( $closest.find('.wpt-repctl').length >= $max) {
// hide button to add more
jQuery(this).hide();
}
});

// add click listener to trash buttons
jQuery(document).on( "mouseup", ".js-wpt-repdelete", function(e){

var $closest = jQuery(e.target).closest('.js-wpt-repetitive');
$closest.find(".js-wpt-repadd").show();
});
});

#1625513

I'll try. Fill in credentials to let me login in your next reply, I'll make it private. ** Make a database backup before sharing credentials. **

Please share the URL of the page when the form is displayed and the form name or ID.

#1626447

Hi Jamal,

I figured it out. Thanks for your help with this. Learned a lot about JQuery in the process which was helpful for other things.

#1626459

My issue is resolved now. Thank you!