0

Ok, so any time I try to view a page on my Drupal 7 site while I am using either drupal_add_js(drupal_get_path('module', 'floormap') . '/includes/javaScript.js'); or drupal_add_js('http://code.jquery.com/jquery-1.10.2.js', 'external');

The admin menu is hidden, As soon as I comment them out, it is back.

First, do I need to include code.jquery.com in Drupal, or is it already there?

Next, I went to my jS file, and made it so that on DOMContentLoaded, it checks the page url, if it isnt the url of my module, nothing is executed...I put in an alert(); and it is only alerting on my pages, but somehow the menu is being hidden still. Why is it still happening on other pages if my jS is only being executed on my module's URL? It seems like just having this file included breaks everything.

function checkPage() {

    if (window.location.pathname == '/floormap_page'){
        alert(window.location.pathname);
        hideAgentInfo();    
    }else if (window.location.pathname == '/floormap_page/setup_floormap') {
        alert(window.location.pathname);
        coordGrabber();
    }
}

function displayAgentInfo(top,left,floormap,uid) {

    var bubble_info = '';
    bubble_info += floormap+','+uid;

    $.ajax({
        type: "POST",
        url: Drupal.settings.basePath + 'floormap_callback',
        data: {'bubble_info':bubble_info},
        success: function(data){
        document.getElementById('agent_info_bubble').innerHTML = data;
        document.getElementById('agent_info_bubble').style.display = "block";
        document.getElementById('agent_info_bubble').style.top = top+'px';
        document.getElementById('agent_info_bubble').style.left = left+'px';
    }
    });



}
function hideAgentInfo() {
    document.getElementById('img').style.height = '550px';
    document.getElementById('img').style.width = 'auto';
    document.getElementById('agent_info_bubble').style.display = "none";
    document.getElementById('agent_info_bubble').innerHTML = '#';

}

document.addEventListener("DOMContentLoaded", checkPage, false);

I've noticed that the admin menu is retieved using $.ajax get, I'm using $.ajax post in my jS, could that be causing issues? Again though, the post is only happening on the pages with my module's URL....

Another note, when I look at the page's source code, the div for the admin menu isn't there at all, it isn't just not visible. That is why I'm getting the impression that it's an issue with the GET function. When I'm watching the log with firebug, it show's the GET when everything is commented out. When my files are included, firebug doesn't show the GET.

Here is a link to my javaScript file if there is anything else you need from it. https://gist.github.com/anonymous/9916901

This is what the firebug console gives me if I have ANY drupal_add_js() in my module's inc file:

ReferenceError: jQuery is not defined

jQuery.noConflict();

drupal.js?n3ddny (line 5) ReferenceError: jQuery is not defined

})(jQuery);

contex...s?v=1.0 (line 52) ReferenceError: jQuery is not defined

jQuery(document).ready(function($) {

scripts.js?n3ddny (line 1) ReferenceError: jQuery is not defined

jQuery(document).ready(function() {

scripts.js?n3ddny (line 1) ReferenceError: jQuery is not defined

})(jQuery);

admin_...?n3ddny (line 397) ReferenceError: jQuery is not defined

})(jQuery);

scripts.js?n3ddny (line 32) ReferenceError: jQuery is not defined

jQuery(document).ready(function() {

main.js?n3ddny (line 1) ReferenceError: jQuery is not defined

...odules/custom/TLSConnectPackage/TLSApplicationFilter/TLSApplicationFilter.cs...

app.lo...bal.com (line 58)

If I remove drupal_add_js() the only thing that shows in the console is the GET for the admin menu.

0

1 Answer 1

1

Drupal comes with jQuery so you don't need to add it. You should use https://drupal.org/project/jquery_update when trying to use a newer version of jQuery; doing it the way you are currently can cause unknown side effects.

Your Answer

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

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