Skip to content

Instantly share code, notes, and snippets.

@dislokacia
Created July 1, 2022 08:06
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save dislokacia/b99db3f307ab30a06644b64997dd93ec to your computer and use it in GitHub Desktop.
JetEngine media field text after upload
jQuery(document).ready(function( $ ){
$('.jet-engine-file-upload__fields').each(function(index){
let upload = $(this).find('.jet-engine-file-upload__input');
$(this).append('<input type="button" class="addfile" value="Choose file"/>');
$(this).append('<label class="labeladdfile">Choose file</label></div>');
let labelAdd = $(this).find('.labeladdfile');
let buttonAdd = $(this).find('.addfile');
let uploadValue = $(this).find('.jet-engine-file-upload__value');
$(this).find('.jet-engine-file-upload__input').css('display','none');
$(this).find('.addfile').click(function () {
upload.trigger('click');
});
let buttonDelete = $(this).siblings('.jet-engine-file-upload__content').find('.jet-engine-file-upload__files');
$(this).find('.jet-engine-file-upload__input').on('change', function(){
if( uploadValue[0].value === "is-hidden" ){
labelAdd.html("Choose file");
} else {
labelAdd.html("file uploaded");
buttonAdd.attr('value', 'File Uploaded')
}
buttonDelete.on('click', function(){
labelAdd.html("Choose file");
buttonAdd.attr('value', 'Choose file')
});
});
});
});
@dislokacia
Copy link
Author

Add this code to this plugin https://prnt.sc/a1ft537XqIOT https://prnt.sc/RTJl-tOyOqsf
And it will work like on video https://www.loom.com/share/7d91130691f7444b942d145d5991b6de
Code is only for JetEngine Forms only
You can change the text of the button and label, as you need
All stylings for button will be taken from the theme

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment