0

I am making my mobile site and our navigation is a bar at the top which when you click expands and shows the categories. However on any pages with the layout class col2-left-layout the navigation doesn't expand, i have checked the console and it say there is an error in my script.js saying Uncaught TypeError: undefined is not a function

and it is referring to this line

if ($('.col-left').length) $('.col-left').masonry({itemSelector : '.block', isResizable:true, isAnimated:true});

I dont understand why this is happening on only pages with certain layouts, could anyone shed some light on the situation please?

Is there a way of changing the page layout depending on the screen size, for example if viewing on a mobile device the layout changes from col2_left_layout to col1_layout??

2
  • I'd imagine masonry isn't loaded correctly on that layout. If you open the console in Chrome on that page and type $('.col-left').masonry what does it show? Commented Jan 13, 2015 at 11:42
  • Uncaught TypeError: Cannot read property 'masonry' of null, If you meant just type that into the console and click enter?
    – Adam Allen
    Commented Jan 13, 2015 at 11:47

1 Answer 1

1

The most likely problem is that masonry is the jQuery plugin and on this page $ is prototype rather than jQuery at the point the code is called. Try changing it to..

if (jQuery('.col-left').length) jQuery('.col-left').masonry({itemSelector : '.block', isResizable:true, isAnimated:true});
8
  • Still get the same error
    – Adam Allen
    Commented Jan 13, 2015 at 11:56
  • If you type jQuery in the console, what do you get? Commented Jan 13, 2015 at 11:57
  • I typed in jQuery in the console and hit eneter it comes back with function (a,b){return new e.fn.init(a,b,h)}
    – Adam Allen
    Commented Jan 13, 2015 at 11:59
  • And jQuery('.col-left')? Commented Jan 13, 2015 at 12:00
  • Returns my div that is called col-left sidebar <div class="col-left sidebar">
    – Adam Allen
    Commented Jan 13, 2015 at 12:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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