0

EDIT: I shouldn't have asked this question. See my answer below.

I have my own custom template on Joomla 4.0.6 with a simple scroll-to-top function.

If I open edit an article on the front end, however, and select any function that results in a pop-up modal - e.g. media select in either Content > CMS Content or in the 'Images and Links' tab I get an error via the browser inspector saying:

"Uncaught TypeError: scrollToTopBtn is null"

I understand partly why this is happening as the modal is in an iframe.

When the modal is opened, the class modal-open is added to the body tag.

So, I thought I'd wrap the JS in this:

if (!document.querySelector('.modal-open')) {
  //my scroll-to-top script here
}

But it doesn't work. Any suggestions gratefully appreciated.

It would also be great if someone could add 'Joomla-4x' to the Tags below.

5
  • 1
    In relation to your request for a new tag: Do we need both the joomla-4.x and joomla-4 tags? I have asked about best tag creation practices among the hundreds of mods in Stack Exchange and opinions vary across 3 or 4 popular strategies. After the 2022 moderation election, the new moderation team should come to a decision about how tagging should be standardised on JSE with the intention of best serving this community and cooperating with other communities that may migrate questions to JSE.
    – mickmackusa
    Jan 22 at 23:26
  • Re Joomla-4 tags. I'm not sure it matters which. Currently neither option appears when you type 'Joomla', only variations on Joomla 3.
    – Gillian
    Jan 23 at 12:36
  • Please never resolve a question (anywhere in the Stack Exchange Network) by editing "SOLVED" into the question. Whenever you realise a soluyion, you should post your resolution as an educational answer. It is completely okay and even encouraged for users to answer their own questions. Please take our tour to familiarise yourself with how our Q&A works.
    – mickmackusa
    Jan 23 at 19:06
  • Sorry. I thought about adding an 'answer' but I was trying to say that in fact there was no question to answer because I had made a stupid mistake.
    – Gillian
    Jan 24 at 17:31
  • Okay, there are two ways to go. If you feel that your problem and resolution will be of absolutely zero use to future researchers, then you have the power to self-delete the question/page while there are no upvoted answers. Even if you feel the problem was basic, trivial, foolish, obscure, etc., you are still absolutely allowed to answer your own question. If you do, rollback your edit and add an answer. My opinion is that JSE needs "more" -- so even pages that are not inherently clever can be helpful in steering a researcher's thinking. I'll leave the decision to you.
    – mickmackusa
    Jan 24 at 21:01

1 Answer 1

0

I was an idiot - I had missed a closing <\div> in my index.php so entirely my fault.

There is now no need to block the script when a modal pops up as the error no longer appears.

1
  • Please award your answer the green tick to prevent the system bumping this page for renewed attention.
    – mickmackusa
    Mar 1 at 1:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.