Omitting Drupal's admin overlay from selectors

I had an issue recently, where I was using a selector to add menu tabs to the edge of the content area. Getting them to appear wasn't the issue. Getting them NOT to appear on admin overlays was.
The body class on which my selector was based didn't change when an admin overlay covered the page. It was still .front. So, how to do the equivalent of the following pseudo-code?
if body class = front but not an admin overlay?
What DOES change in the markup is the html tag. It has the class

What a difference a space makes

Sometimes you need your selector to look for two classes...but what do you do when both classes are for the same element?
In normal circumstances, you might be looking to select class=red and class=blue
<div class="red">
  <div class="blue">
and would use the selector
$('.red .blue')
However, if you need to select the element that has both red and blue as its classes
<div class="red blue">

To-Go Menu

Have you ever wanted to have a menu item open in a new window, when clicked? The standard menu dialog does not offer the option of a target for the menu link. So, what to do? A little jQuery magic!

1. Inspect the menu item, or view the page source, and find it's id...something like this:

<div id="menu-231">
  <a href="wherever">My menu link</a>


2. Add the following snippet to your theme. How you will add it depends...see the footnote at the end:

Maturity is great, to a point, for wine, cheese and men, but not for jQuery 1.2.6

Drupal 6 has jQuery 1.2.6 somewhat hardwired. The jQuery update module can get you to 1.3.2, still a long way from the current version. Drupal 7 has hook_js_alter, which will allow you to conditionally override the built-in version.

If you're looking to do some UX magic and want the latest greatest version, you can do the following:


The Secret to drupal_add_js

drupal_add_js() doesn't add javascript or jquery to your Drupal page? Let's take a look at why, and how to fix it.

Sometimes we need javascript or jquery in our Drupal page. If the script needs to appear on every page, we could just add it to our page template, but what if we want it only on one page?

We could create a page template for the page on which we want it. If the requirement is static and small, that is a way to do it, though putting the script directly in the template is not the best-practices way to do it, for several reasons.

Subscribe to jquery