最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Overriding Drupal javascript behaviors - Stack Overflow

programmeradmin0浏览0评论

I want to override a bit of core drupal behavior on the ment form.

If you make a ment as an anonymous user, your name and mail are stored in a cookie, and then javascript fills out the appropriate fields in subsequent ment forms using this code below:

Drupal.behaviorsment = function (context) {
  var parts = new Array("name", "homepage", "mail");
  var cookie = '';
  for (i=0;i<3;i++) {
    cookie = Drupalment.getCookie('ment_info_' + parts[i]);
    if (cookie != '') {
      $("#ment-form input[name=" + parts[i] + "]:not(ment-processed)", context)
        .val(cookie)
        .addClass('ment-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.

I want to override a bit of core drupal behavior on the ment form.

If you make a ment as an anonymous user, your name and mail are stored in a cookie, and then javascript fills out the appropriate fields in subsequent ment forms using this code below:

Drupal.behaviors.ment = function (context) {
  var parts = new Array("name", "homepage", "mail");
  var cookie = '';
  for (i=0;i<3;i++) {
    cookie = Drupal.ment.getCookie('ment_info_' + parts[i]);
    if (cookie != '') {
      $("#ment-form input[name=" + parts[i] + "]:not(.ment-processed)", context)
        .val(cookie)
        .addClass('ment-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.

Share Improve this question asked Oct 27, 2010 at 21:26 lazysoundsystemlazysoundsystem 2,17924 silver badges23 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 6

If you have a custom module, you should be able to overwrite Drupal.behaviors.ment, or delete it.

something like

drupal_add_js('delete Drupal.behaviors.ment','inline');

Of course if you already have a js file being included put it there rather than inline.

发布评论

评论列表(0)

  1. 暂无评论