开发者

Overriding Drupal javascript behaviors

开发者 https://www.devze.com 2023-01-22 12:03 出处:网络
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 appropr

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.behavio开发者_C百科rs.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.

0

精彩评论

暂无评论...
验证码 换一张
取 消