The path to the drupal module from inside javascript

Is there any way to get the path to the drupal (7) module from which .js was loaded?
I know JS is an interface, but maybe Drupal passes this information in a Drupal object?

Basically I want to do something like this:

$('#selectable_html').load("selectable_html.html"); 

But since Drupal builds pages on the fly, this request is converted to "http://___/node/add/selectable_html.html" , which is clearly incorrect.

+4
source share
1 answer

You can pass things into Javascript via Drupal using drupal_add_js using the 'setting' parameter.

Add Settings ('Settings'): Adds settings to the Drupal global repository. JavaScript Settings. Some page parameters are required by some modules to function correctly.

drupal_add_js (array ('myModule' => array ('key' => 'value')), 'Parameter');

Then you can pass the path returned from drupal_get_path ('module', 'name') and access it in Javascript using Drupal.setting.

All settings will be available on Drupal.settings.

+8
source

All Articles