ajax - Path to drupal module from inside of javascript - Stack Overflow

Is there a way to get the drupal(7) module path from which the .js was loaded?I know that JS is a fron

Is there a way to get the drupal(7) module path from which the .js was loaded?
I know that JS is a front-end language, but possibly Drupal passes that info in the Drupal object somehow?

Basicly I want to do something like this:

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

But since Drupal constructs pages on the fly this request transforms to "http://___/node/add/selectable_html.html", which is obviously wrong.

Is there a way to get the drupal(7) module path from which the .js was loaded?
I know that JS is a front-end language, but possibly Drupal passes that info in the Drupal object somehow?

Basicly I want to do something like this:

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

But since Drupal constructs pages on the fly this request transforms to "http://___/node/add/selectable_html.html", which is obviously wrong.

Share Improve this question edited Feb 26, 2014 at 16:12 Robbert 6,6026 gold badges37 silver badges64 bronze badges asked Jul 28, 2011 at 12:17 NoRiMNoRiM 435 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 8

You can pass things to Javascript via Drupal using drupal_add_js using the 'setting' option.

Add settings ('setting'): Adds settings to Drupal's global storage of JavaScript settings. Per-page settings are required by some modules to function properly.

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

You could then pass the path returned from drupal_get_path('module', 'name') and access it in Javascript using Drupal.setting.

All settings will be accessible at Drupal.settings.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745469569a4629073.html

相关推荐

  • ajax - Path to drupal module from inside of javascript - Stack Overflow

    Is there a way to get the drupal(7) module path from which the .js was loaded?I know that JS is a fron

    2小时前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信