Behavior being fired on backend causes AJAX error I am using jQuery Update to bump up the jQuery version on the front end, and keep the default 1.4 on the backend. 

On a custom filter form on the home page, i use jQuery on, and wrap it in a behavior so it still works after an ajax event on that page.

The problem is that for some reason, when editing the page, and adding a new field collection row when Ajax is fired, the jQuery is being called, and an error happens because jQuery on did not exist in 1.4.


  VM787:31 Uncaught TypeError: $(...).on is not a function


Steps to fix...


I am using drupal_add_js but I check that if (!path_is_admin(current_path())) {//jQuery} to make sure it isnt called on the admin pages
I am certain the JS is not on the admin pages, but after ajax, it is called because its in a behavior. 


Is there a way to say which behaviors should run on the admin side, and which shouldnt?
Funny how sometimes you write out the question, and it makes you think about it in a different way!

The issue is that the behavior is obviously saved somewhere and called on an ajax event, EVEN if the js is not being called on that page! This was funny behavior to me, but the quick fix (maybe not the right fix) was to check the current path, and not run the JS inside that behavior if the path had "edit" in it.

Drupal.behaviors.myBehavior = {
  attach: function (context, settings) {
    (function($) {

        jQuery(document).ready(function() {

        var pathname = window.location.pathname;
            // If the page does NOT contain edit
            if (! (pathname.indexOf('edit') &gt; -1) ) {

               // All of the JS stuff....

            }
        });

    }(jQuery));
  }
};


I will leave this question open for a few days as I would be interested to see if there's a better way of doing this. Ideally some way to control which behaviors are called on which pages?