Drupal Form 无法访问 javascript 函数(错误“不是函数”)
使用 drupal 和 lightbox2 打开表单。该表单来自自定义模块。
该模块有一个设置: 'onsubmit' => '返回表单提交(此);'这似乎工作正常。
我已将functions.js 包含在theme.info 文件中并且它已显示,我可以打开该文件并查看该函数。
由于某种原因,当我提交表单时,我不断收到“form_submission not a function”。
if(Drupal.jsEnabled)
{
$(document).ready(function() {
// Call back function for AJAX call
var form_submission = function(responseText) {
alert (responseText);
}
// preventing entire page from reloading
return false;
});
}
using drupal with lightbox2 to open a form. this form is from a custom module.
the module has a setting: 'onsubmit' => 'return form_submission(this);' and that appears to be working correctly.
I've included the functions.js in the theme.info file and it's showing up, i can open that file and see the function.
for some reason, i keep getting "form_submission not a function" when i do submit the form.
if(Drupal.jsEnabled)
{
$(document).ready(function() {
// Call back function for AJAX call
var form_submission = function(responseText) {
alert (responseText);
}
// preventing entire page from reloading
return false;
});
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您的 form_submission 函数是其内部匿名函数的本地函数(即文档准备函数)。
您需要在文档之外的全局范围内声明该函数。您至少需要声明变量 form_submission。然后您就可以将该功能附加到您想要的任何位置。
Your form_submission function is local to the anonymous function it's inside (ie the document ready function).
You need to declare the function in a global scope, outside of the document ready. You at least need to declare the variable form_submission. You will then be able to attach the function on to it wherever you wish.
form_submission 必须是一个已定义的函数。
或者也尝试
form_submission has to be a defined function.
or also try
这并不是一个完美的答案,但我从 document.ready jquery 包装器中删除了该函数,并且它接受了它。
Not that this is the perfect answer, but I removed the function from within the document.ready jquery wrapper and it picked up on it.