Looking for $(document).ready(function() { in the js code, but can't find it

Respondido


Publicado 19 de mai. de 2021

Hello! I'm trying to update the js code, and I'm supposed to add the new code after the following code, but can't find it:

 

$(document).ready(function() {

2

3

3 comentários

Hey, you are adding the custom code in the incorrect bracket, now, you just need to copy this code and paste it into your script file:

// Cut your custom code from there and paste here with correct format like this

$(document).ready(function (){
$("label[for='request-attachments']").text("Upload current image");
});

document.addEventListener('DOMContentLoaded', function() {
// Key map
var ENTER = 13;
var ESCAPE = 27;
var SPACE = 32;
var UP = 38;
var DOWN = 40;
var TAB = 9;

function closest (element, selector) { // I have move your custom code at the top
if (Element.prototype.closest) {
return element.closest(selector);
}
do {
if (Element.prototype.matches && element.matches(selector)
|| Element.prototype.msMatchesSelector && element.msMatchesSelector(selector)
|| Element.prototype.webkitMatchesSelector && element.webkitMatchesSelector(selector)) {
return element;
}
element = element.parentElement || element.parentNode;
} while (element !== null && element.nodeType === 1);
return null;
}

 

and don't forget to add this jQuery Library at the document_head.hbs template:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>

 

If any issue let me know.

Thanks

Ifra

0


Thank you for that :) So, we're on API v2 and I found the second code that you mentioned and added the below code:

 

$("label[for='request-attachments']").text("Upload current image");

 

I added it here:

document.addEventListener('DOMContentLoaded', function() {
// Key map
var ENTER = 13;
var ESCAPE = 27;
var SPACE = 32;
var UP = 38;
var DOWN = 40;
var TAB = 9;

function closest (element, selector) $("label[for='request-attachments']").text("Upload current image"); {
if (Element.prototype.closest) {
return element.closest(selector);
}
do {
if (Element.prototype.matches && element.matches(selector)
|| Element.prototype.msMatchesSelector && element.msMatchesSelector(selector)
|| Element.prototype.webkitMatchesSelector && element.webkitMatchesSelector(selector)) {
return element;
}
element = element.parentElement || element.parentNode;
} while (element !== null && element.nodeType === 1);
return null;
}

 

Whici I think is within the correct brackets. Trying to change the text on "Attachments", but it's not updating. Any idea what I could be doing wrong?

0


Hey, Which API version are you using? API v1 or API v2?

If you are using API v2; now you will have to add jQuery Lib (library) and add the new code with this function if you want to use jQuery:

$(document).ready(function() {

// Add new code here

});

because jQuery isn't being used in the API v2.

 

And

 

Find this function, you can update your JS code inside this function:

// In API V2

document.addEventListener('DOMContentLoaded', function() {

 

Thanks

Team

 

 

0


Publicação fechada para comentários.

Não encontrou o que estava procurando?

Nova publicação