使错误,警告或通知消息出现的核心JavaScript函数? [英] Core javascript functions to make error, warning or notice messages appear?

查看:48
本文介绍了使错误,警告或通知消息出现的核心JavaScript函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道强制drupal javascript的核心功能是什么?更重要的是,它必须与Message Effects配合使用( http://drupal.org/project/messagefx ) 。

Does anyone know what the core drupal javascript functions are to force an error message? More importantly, it must work with Message Effects (http://drupal.org/project/messagefx).

使用JS主题,您可以调用以下代码:(这是JavaScript代码)

With JS Theming you can call these: (this is javascript code)

Drupal.messages.set("The Message!", 'error');

但是,它不与Message Effects挂钩,并且在禁用JS主题设置之后,此功能不再

But, it doesn't hook into Message Effects, and after disabling JS theming, this function no longer works.

推荐答案

似乎您问错了问题。您看到的状态,警告和错误消息未被javascript调用。而是由 drupal_set_message()函数生成的。通过将消息保存在该用户的会话表中,然后在该用户(重新)加载页面时将它们打印出来,便可以正常工作。在page.tpl.php中最终以$ messages结尾。我相信没有此功能的javascript版本,但是您可以模仿它。就像在页面上插入一些HTML一样简单。

It seems like you have asked the wrong question. The status, warning, error messages that you see, is not invoked by javascript. Instead they are generated by the drupal_set_message() function. It work, by saving the messages in the session table for that user, and then they get printed whenever that user (re)load a page. It ends up as $messages in the page.tpl.php. I believe that there are no javascript version of this functionality, but you could mimic it. It's no harder than to insert some html on the page, something like.

$("#message").append('<div class="message error">The error message</div>');

我不确定确切的html结构,而且每个主题的HTML格式也有所不同,但是你明白了。如果您采用这种方法,则还需要连接到messagefx模块的js,以添加效果,但这并不难。

I'm not sure about the exact html structure, and it cal also vary from theme to theme, but you get the idea. If you do take this approach, you will also need to hook into the messagefx module's js, to add the effect, but this shouldn't be too hard.

这篇关于使错误,警告或通知消息出现的核心JavaScript函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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