weixin_33696106 2011-12-28 13:56 采纳率: 0%
浏览 30

如何清除Drupal.settings?

The problem is that I am using ajaxed form with clientside validation which uses Drupal.settings to get some data. As an example to validate age I set following data to drupal settings:

drupal_add_js(array(
'viewpoint_profile' => array(
  'year' => date('Y'),
  'month' => date('m'),
  'day' => date('d')
)), 'setting');

But whenever form is reloaded with ajax it merges above settings to Drupal.settings and if on first call Drupal.settings.viewpoint_profile.year == 2011, after ajax reload it is Drupal.settings.viewpoint_profile.year == array(2011, 2011), so I can't use this in js as a string any more.

So basically it would be nice to clear settings for viewpoint_profile before adding them, but I didn't manage to find how? or may be there is another way to solve this problem?

  • 写回答

1条回答 默认 最新

  • 游.程 2014-12-08 20:34
    关注

    If you must use the drupal settings than why not as those values to an array.

    drupal_add_js(array(
      'viewpoint_profile' => array(array(
        'year' => date('Y'),
        'month' => date('m'),
        'day' => date('d')
    ))), 'setting');
    

    You can also add a key that will be passed with the form.

    评论

报告相同问题?

悬赏问题

  • ¥15 手机连接电脑热点显示无ip分配
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大