Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

159
Views
jQuery Collapse function throws error on upgrade of WordPress and PHP

I have upgraded an old WordPress site to the latest WordPress. PHP version was also upgraded. The site had a custom sidebar menu where opening and closing was controlled with a custom.js script. The menu no longer toggles.

After the upgrade the following error appeared in the console:

Uncaught TypeError: $submenu.collapse is not a function.

Not quite sure what the issue is.

jQuery('.menu-container li.menu-item-has-children').each(function() {
  var $this = jQuery(this);
  var $toggler = $this.find('a').first();
  var $submenu = $this.find('.sub-menu');

  $submenu.addClass('collapse');

  if ($submenu.find('.current_page_item').length > 0) {
    $submenu.addClass('in');
  }

  $toggler.on('touchstart click', function(e) {
    e.preventDefault();
    e.stopPropagation();
    $submenu.collapse('toggle');
  });

  $submenu.on('shown.bs.collapse', function() {
    $this.addClass('expanded');
  });

  $submenu.on('hidden.bs.collapse', function() {
    $this.removeClass('expanded');
  });
});
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Collapse is a bootstrap function. The boostrap in the old theme, the dependency was not properly done.

Before Fix

 wp_enqueue_script( 'secd-bootstrap-bootstrap', get_template_directory_uri() . '/js/bootstrap.min.js', array('jquery'), '20140319', true );
wp_enqueue_script( 'secd-bootstrap-custom', get_template_directory_uri() . '/js/custom.js', array('jquery'), $current_filemodtime );

After Fix

wp_enqueue_script( 'secd-bootstrap-custom', get_template_directory_uri() . '/js/custom.js', array('secd-bootstrap-bootstrap'), $current_filemodtime );
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!