在 Drupal 中为 OnLoad 添加一个函数 [英] Add a function to OnLoad in Drupal

查看:24
本文介绍了在 Drupal 中为 OnLoad 添加一个函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的一个皮肤/主题的左侧栏中有一个 HTML/文本默认模块.我在那里有一些 Javascript 我试图将今天的日期设置为我的 javascript 日期下拉列表.我无法使用body.onLoad",因为 Drupal 以某种方式阻止了它?

I have a HTML/text default module in the left bar of one of my skins/themes. I have some Javascript in there I'm trying to set today date to my javascript date dropdowns. I am unable to use 'body.onLoad' because Drupal is blocking it somehow?

我找到了一个解决方案,说我可以在这里添加我的 javascript 函数:如果(isJsEnabled()){addLoadEvent(yourCustomJSFunction);}

I found a solution saying I can add my javascript function here: if (isJsEnabled()) { addLoadEvent(yourCustomJSFunction); }

如果我只使用默认的 HTML/文本模块,我该如何添加?

How can I add that if I'm just using a default HTML/text module?

谢谢!

推荐答案

Drupal 使用 jQuery JavaScript 库.您编写的用于 Drupal 的任何 JavaScript 最好也应该使用 jQuery.查看 api 上的 JavaScript 启动指南.drupal.org 了解一些基础知识,特别是 Drupal.behaviors 部分.

Drupal uses the jQuery JavaScript library. Any JavaScript you write to work with Drupal should ideally use jQuery as well. Check out the JavaScript Startup Guide on api.drupal.org for some basics, particularly the Drupal.behaviors section.

这篇关于在 Drupal 中为 OnLoad 添加一个函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆