0

I have some custom code which randomises a joomla video, this works fine outside of Joomla as can be seen at this fiddle, however when the code is placed into a Joomla custom module and published the videos do not randomise as can be seen here under the module heading FAB PLACES TO GO ON OYG (2).

For testing I have disabled Cloudflare plus JCH and Jotcache, but the same video loads everytime the page loads. I am seeing a JS error in the console...

(index):1045 Uncaught ReferenceError: _ is not defined
    at onPlayerReady ((index):1045)
    at M.h.G (www-widgetapi.js:48)
    at Y.h.o (www-widgetapi.js:92)
    at Y.h.H (www-widgetapi.js:105)
    at Wa.g (www-widgetapi.js:81)
    at Oa.f (www-widgetapi.js:70)

Any ideas how I can get this working? I;ve been looking at getting it working for some time now and am completely stuck. The JS is inline between tags.

  • The 2nd link you provided still goes to the JSFiddle. I dont know why, but you're using the lodash library, so my guess is that it's not being loaded on your site, hence the _ console error. – Lodder Apr 16 '18 at 9:14
  • It was the lodash library causing the issue. I have used num = Math.floor(Math.random() * 11); This has fixed the issue. – Dtorr1981 Apr 16 '18 at 13:26
  • Please would you mind adding this as a proper answer below and marking it as accepted? – Lodder Apr 16 '18 at 15:08
0

It was the lodash library causing the issue. I have used

num = Math.floor(Math.random() * 11); 

This has fixed the issue.

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.