behaviors javascript executing I want to pass params via Drupal to my JS file. I have no problem fetching them with the code below,
the problem is that as the  $(document).bind('leaflet.map'  function executes FIRST, it is not able to find the
user_name parameter 

my_module.module

  function my_module_preprocess_html(&amp;$variables) {

  $user_name=$GLOBALS['user']-&gt;name;
  drupal_add_js(array('my_module' =&gt; array('user_name' =&gt; $user_name)), array('type' =&gt; 'setting'));
  drupal_add_js(drupal_get_path('module', 'my_module') . '/js/external.js');
  }


external.js

(function($) {

Drupal.behaviors.fewo_map= {

 attach: function (context, settings) {

 alert('get params');
 //we can fetch the data
 user_name=settings.fewo_map.user_name;
}


}

$(document).bind('leaflet.map', function(e, map, lMap) {

//it fires first, so is unable to get user_name data
alert('leaflet')

console.info(user_name)
})


If I do... 

(function($) {

 Drupal.behaviors.fewo_map= {

 attach: function (context, settings) {

  $(document).bind('leaflet.map', function(e, map, lMap) {
    alert('leaflet')

    console.info(user_name)
    })
  }
 }
})


the result is the same

Also tried using JS injector, no success neither. I need the user_name as parameter to define the settings inside leaflet 'function'
Thanks
Difficult to separate your php from javascript, but if you set js variable with this php code it should execute first and can be used within leaflet js function later:

&lt;?php render('&lt;script&gt;var username = "'.$GLOBALS['user'].'";&lt;/script&gt;'); ?&gt;