Javascript“”在 Drupal 中

发布于 2024-09-16 03:18:26 字数 376 浏览 3 评论 0原文

我正在尝试集成 javascript 库以在表格上进行拖放 进入我的自定义 Drupal 模块的一页。我已经使用 drupal_add_js 包含了 js 文件,但我不知道如何初始化它。

该库的文档指出应该调用 init 函数,例如

<body onload="REDIPS.drag.init()">

How would I do that in Drupal?或者 Drupal 有更好的初始化脚本的方法吗?

I'm trying to integrate a javascript library for drag&drop on tables into one page of my custom Drupal module. I've included the js file using drupal_add_js, but I don't know how to initialize it.

The documentation for that library states that an init function should be called like

<body onload="REDIPS.drag.init()">

How would I do that in Drupal? Or has Drupal some better way of initializing the script?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

我ぃ本無心為│何有愛 2024-09-23 03:18:26

Drupal 对此有自己的机制,包括向 Drupal.behaviors 添加属性。请参阅此页面:http://drupal.org/node/205296

Drupal.behaviors.redipsDragBehavior = function() {
    REDIPS.drag.init();
};

从链接页面:

定义为属性的任何函数
Drupal.behaviors 将在以下情况下被调用
DOM 已加载。

Drupal has its own mechanism for this, involving adding a property to Drupal.behaviors. See this page: http://drupal.org/node/205296

Drupal.behaviors.redipsDragBehavior = function() {
    REDIPS.drag.init();
};

From the linked page:

Any function defined as a property of
Drupal.behaviors will get called when
the DOM has loaded.

宫墨修音 2024-09-23 03:18:26

您可以尝试在与其他 add_js 相同的函数中添加另一个 drupal_add_js 调用:

drupal_add_js('REDIPS.drag.init();','inline','header',true);

最后一个参数“true”是推迟脚本的执行。
我希望这能在某种程度上有所帮助!

You could try adding another drupal_add_js call in the same function as your other add_js:

drupal_add_js('REDIPS.drag.init();','inline','header',true);

The last param "true" is to defer the execution of the script.
I hope that helps in some way!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文