0

I have some custom javascript modules in my Drupal site that worked perfect. Yesterday I performed an update for bootstrap and unfortunately the custom javascript modules doesn't work. I get bellow errors to chrome developer tool console:

Uncaught TypeError: $ is not a function

If you want to see the problem, you can here: http://www.neashmera.gr/

5
  • How did you update your site? Did you use jQuery Update?
    – Huelfe
    Nov 10, 2015 at 9:23
  • what jquery version you are using right now?
    – WaQaR Ali
    Nov 10, 2015 at 9:24
  • I have only update the bootstrap theme of drupal. I use jQuery Update module. Nov 10, 2015 at 9:24
  • In jQuery Update module I have 1.7 JQUERY VERSION Nov 10, 2015 at 9:26
  • show up your custom code.
    – WaQaR Ali
    Nov 10, 2015 at 9:33

1 Answer 1

5

locate the javascript file where you have your error throwing code:

$(document).ready(function(){var weatherAPI='http://api.openweathermap.org/data/2.5/weather';var data={q:"Athens",units:"metric",appid:"b0847a3de80121926a9f428c35f611f8"};function showWeather(weatherReport){var iconURL='http://openweathermap.org/img/w/'+ weatherReport.weather[0].icon+'.png';var imgE=document.createElement('img');$("#open-weather").attr('src',iconURL);$('#temperature').html('Αθήνα '+ weatherReport.main.temp+'°');}
$.getJSON(weatherAPI,data,showWeather);});;function dateAndTime(){var date=new Date();var day;var dayOfMonth=date.getDate();var month;var h=date.getHours();var m=date.getMinutes();var s=date.getSeconds();switch(date.getDay()){case 0:day="Κυριακή";break;case 1:day="Δευτέρα";break;case 2:day="Τρίτη";break;case 3:day="Τετάρτη";break;case 4:day="Πέμπτη";break;case 5:day="Παρασεκυή";break;case 6:day="Σάββατο";break;}
switch(date.getMonth()){case 0:month="Ιανουαρίου";break;case 1:month="Φεβρουαρίου";break;case 2:month="Μαρτίου";break;case 3:month="Απριλίου";break;case 4:month="Μαϊου";break;case 5:month="Ιουνίου";break;case 6:month="Ιουλίου";break;case 7:month="Αυγούστου";break;case 8:month="Σεπτεμβρίου";break;case 9:month="Οκτωβρίου";break;case 10:month="Νοεμβρίου";break;case 11:month="Δεκεμβρίου";break;}
if(h<10){h="0"+ h;}
if(m<10){m="0"+ m;}
if(s<10){s="0"+ s;}
var time=h+":"+ m+":"+ s;$('#time-now').html(time);setTimeout('dateAndTime();','1000');var myDate=day+', '+ dayOfMonth+" "+ month;$('#date-now').html(myDate);return true;};

then wrap it with

(function($) {
..
})(jQuery);

or replace the $ sign with jQuery

1
  • It works :) Thank you very much I spent a lot of hours to fix it Nov 10, 2015 at 9:36

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