prevent script to run twice after 2 ajax loads I use colorbox node, which loads a node inside colorbox overlay. Inside colorbox I load a jquery script to add some parameters to all links inside. However, the loading is done by 2 ajax calls and I end up with doubled parameters on all links. 
I tried to use .once() but that does not return anything, probably because it fires after first ajax call. How to wait until second ajax call? Thank you.

my script:

(function($){ // Create local scope.
Drupal.behaviors.jjj = {
  attach: function (context, settings) {

$('#colorbox #block-book-navigation a', context).once('jjj', function () {
       $("#colorbox #block-book-navigation a").each(function(){

                       $(this).addClass("xxx");
console.log( "test" );               
       });

 });
}}; 
})(jQuery);
I figured it  out. The wrong code came out of misunderstsatnding .once function. "nav" means a class that the selector #colorbox #block-book-navigation would be marked, so code is not fired multiple times on that selector.
http://codekarate.com/blog/drupal-7-prevent-duplicating-javascript-behaviors
Correct code should be:

(function ($) {
  Drupal.behaviors.myCustomJS = {
    attach: function(context, settings) {
      $('#colorbox #block-book-navigation').once('nav', function() {

        $("#colorbox #block-book-navigation a").each(function(){         
            $(this).addClass("colorbox-node");

       });


      });
    }
  };
})(jQuery);