覆盖Drupal的JavaScript行为 [英] Overriding Drupal javascript behaviors
问题描述
如果您以匿名用户的身份发表评论,您的姓名和邮件将存储在一个cookie中,然后JavaScript将使用此代码填写后续注释表单中的相应字段以下:
Drupal.behaviors.comment = function(context){
var parts = new Array(name ,主页,邮件);
var cookie =''; (i = 0; i <3; i ++){
cookie = Drupal.comment.getCookie('comment_info_'+ parts [i]);
if(cookie!=''){
$(#comment-form input [name =+ parts [i] +]:not(.comment-processed),context)
.val(cookie)
.addClass('comment-processed');
}
}
};
如果我不想填写这些字段,我知道我可以擦掉信息进一步的JavaScript,但我确定有一个更干净的方式来做到这一点。
如果你有一个自定义模块,你应该可以覆盖Drupal.behaviors.comment,或者删除它。
像
drupal_add_js('delete Drupal.behaviors.comment ','一致');
当然,如果你已经有一个js文件被包含在它而不是内联。
I want to override a bit of core drupal behavior on the comment form.
If you make a comment as an anonymous user, your name and mail are stored in a cookie, and then javascript fills out the appropriate fields in subsequent comment forms using this code below:
Drupal.behaviors.comment = function (context) {
var parts = new Array("name", "homepage", "mail");
var cookie = '';
for (i=0;i<3;i++) {
cookie = Drupal.comment.getCookie('comment_info_' + parts[i]);
if (cookie != '') {
$("#comment-form input[name=" + parts[i] + "]:not(.comment-processed)", context)
.val(cookie)
.addClass('comment-processed');
}
}
};
If I don't want those fields to be filled in, I know I can just wipe out the information with further javascript, but I'm sure there's a 'cleaner' way to do it.
If you have a custom module, you should be able to overwrite Drupal.behaviors.comment, or delete it.
something like
drupal_add_js('delete Drupal.behaviors.comment','inline');
Of course if you already have a js file being included put it there rather than inline.
这篇关于覆盖Drupal的JavaScript行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!