Joomla 5 Notice

We are pleased to announce that as of January 29, 2024, all of our Joomla extensions are compatible with Joomla 5.

For all who are still updateing from Joomla 3 to Joomla 4: Joomla 4 Migration instructions are available here:

There is now a separate Documentation for Visforms for Joomla 4 and for Visforms for Joomla 5!

Forum

Visforms Subscription user can ask questions in our forum. Please log in with the relevant user first.
Everybody can access the forum for reading.

Please only ask 1 question per topic.

Set "clear-selection" link to always display

More
1 year 5 months ago #8581 by Shaman
Hi devs,

I need to always display the "clear-selection" link on a file input field.
By default it is set to be hidden until a file is selected.

Even by queriing the field after document load, it can't be set to display.

This is the JS is use:
Code:
let clearfiles = document.querySelectorAll(".clear-selection");         for (let i = 0; i < clearfiles.length; i++) {             const clearfile = clearfiles[i];             clearfile.style.display = "block";         }

Can you help me please?

Kind regards,
Claude

More
1 year 5 months ago - 1 year 5 months ago #8582 by Administrator IV
Replied by Administrator IV on topic Set "clear-selection" link to always display
Hello Claude,

it works with the direct setting of the complete HTML attribute 'style'.
In addition, you also have to take care of the existing event handler.
So first remove the existing handler and then attach your own.

Your custom event handler is nothing more than a copy of the original minus the one line that hides the anchor.

The following code works for me:
Code:
jQuery(document).ready(function() {     jQuery('.clear-selection').each(function() {         jQuery(this).attr("style", "display: block;");         jQuery(this).off('click');     });     jQuery("a.clear-selection").on("click", function(e) {         let uploadid = jQuery(this).attr('data-clear-target');         let el = jQuery('#' + uploadid);         el.replaceWith(el.val('').clone(true));         // get the new jQuery object of el         el = jQuery('#' + uploadid);         el.trigger('keyup');         e.preventDefault();         return false;     }); });

Kind regards, Ingmar[/code]

:idea: I recommend you the new and up-to-date documentation for Joomla 4:
docs.joomla-5.visforms.vi-solutions.de/en/docs/
Most of this also applies retrospectively to Joomla 3.
Please only ask 1 question per topic :-).

:idea: Ich empfehle Dir die neue und aktuelle Dokumentation für Joomla 4:
docs.joomla-5.visforms.vi-solutions.de/docs/
Das meiste gilt rückwirkend auch für Joomla 3.
Bitte immer nur 1 Frage pro Thema stellen :-).
Last edit: 1 year 5 months ago by Administrator IV.
The following user(s) said Thank You: Shaman

More
1 year 5 months ago #8583 by Shaman
Thank you Ingmar,

this works like a charm :-)

Kind regards,
Claude

Moderators: Administrator AVAdministrator IV
Powered by Kunena Forum