1

I'm receiving the following two errors, i'm unsure how to fix them. after doing some research this file has had issues before. The solutions did not solve my problem. Could this be a simple script load order?

Uncaught TypeError: Cannot set property 'bootstrap' of undefined (anonymous function) @ bootstrap.js?ny6rj2:13

var Drupal = Drupal || {};

(function($, Drupal){
  "use strict";

  Drupal.behaviors.bootstrap = {
    attach: function(context) {
      // Provide some Bootstrap tab/Drupal integration.

(anonymous function) @ bootstrap.js?ny6rj2:230

})(jQuery, Drupal);
0

Drupal exports in javascript the Drupal variable that has several subitems inside depending on your configuration. Your error suggest that the bootsrap property does not exist (at least yet). You can easily make sure that this is the case by opening the console in your browser (f12 in chrome) and type: console.log(Drupal.behaviors); if the property is not there you cannot use it.

Make sure you re loading the bootstrap library correctly. Usually you can do this by downloading the bootstrap module/theme or by using the libraries module.

Also note that Drupal behaviors intend to run every time an 'ajax' call is made by in a drupal page. I m putting ajax in quotes because drupal actually uses a legacy way for ajax called AHAH

3
  • 3
    This isn't quite right - the error refers to Drupal.behaviors not existing, the OP is trying to initialise Drupal.behaviors.bootstrap, so whether it exists or not would be irrelevant (it would after the code is executed, assuming Drupal.behaviors was an initialised object). As the OP suggests it's likely to be a problem with the order scripts are loaded in, i.e. Drupal.behaviors hasn't been initialised yet, or, more likely juding from the OP's first line, Drupal doesn't yet. Just as an aside, AHAH was a Drupal 6 concept, before behaviours were dreamt up - it's not part of D7 – Clive Nov 22 '15 at 20:21
  • AFAIK d7 still uses the AHAH concept just renamed to AJAX. That is each time something on a form is changed this part of the form is replaced with a new html content. Like in this example api.drupal.org/api/examples/ajax_example%21ajax_example.module/… . A typical jquery Ajax involves a javascript callback that does something when data are retrieved and not necessarily replaces an element in the DOM. Please correct me if I m wrong. – Nikos Tsagkas Nov 23 '15 at 10:05
  • 1
    It's all semantics, AHAH and AJAX are the same thing; they both use an XmlHttpRequest to request data from a server without causing a browser to reload the page. Some people just don't like the idea of calling it AJAX when there's no XML involved, that's all. If you want to get really technical about it, then Drupal 7 definitely doesn't have the concept of AHAH, as all data is returned in JSON format. Don't be confused by jQuery's ajax method, that's also just a wrapper around the XmlHttpRequest API, it doesn't have any effect on what the concepts are called, it's a consumer of AJAX itself – Clive Nov 23 '15 at 10:20
0

If you use Vasil Dinkov` smartmenus plugin for Bootstrap, then jquery.smartmenus.bootstrap.js should be placed AFTER jquery.smartmenus.js, not vice versa.

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.