admin管理员组文章数量:1426072
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.
1 Answer
Reset to default 8You 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.
本文标签: ajaxPath to drupal module from inside of javascriptStack Overflow
版权声明:本文标题:ajax - Path to drupal module from inside of javascript - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745469569a2659689.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论