Reputation: 2708
I'm having problem with Jquery on Drupal.
Here is what I'm trying to achieve, I needed to get the html()
of my primary link. For example one of my primary link have a sub menus/child menus. I need to get those child menus using Jquery. My problem is I can't retrive it using $("#menuID").html()
, it always returns null. It seems that the page was not yet fully loaded when the function was called. I placed it inside $(document).ready()
but still won't work.
file.js
$(document).ready(function(){
console.log($('#id-of-the-menu').html());
});
I called file.js on page.tpl.php
Any help is greatly appreciated.
Upvotes: 1
Views: 227
Reputation: 841
Call in your page.tpl.php the file.js after the "<?php print $scripts ?>
"-tag in the head.
Also if there is more javascript action going on (collapsing menus, ...), look at the source of the page to see if there is inline-javascript and if so, even call your file.js at the bottom of page.tpl.php .
It could be the menu hasn't loaded because a module is preventing it to load in a normal way (but then we'll need more info on the modules you use).
Upvotes: 1