选择项目并触发 onchage ajax 事件后,选择框不会折叠

发布于 2024-12-09 20:45:14 字数 2203 浏览 0 评论 0原文

我正在使用标准 D7 Ajax API 来加载/更改表单元素。

所以我想要得到的是:

制作 3 个依赖的选择框。即,当选择第一个值时,第二个和第三个值会发生变化。第三个选择框取决于第二个选择框。

除了 Opera for Win 之外,所有浏览器都可以正常工作 [Linux 没有问题](我使用的是 v11.51)。 当您从选择框中选择一个项目(在 Opera 中)时,尽管 ajax 事件被触发并且数据已成功加载,但它不会折叠。

如果触发事件后,有什么方法可以折叠选择框吗?

这是表单的 php 代码:

  $form['type'] = array(
    '#type' => 'select',
    '#options' => _bp_filter_get_types(),
    '#attributes' => array('onReady' => "alert('Hello!');return false;"),
    '#prefix' => '<p>',
    '#suffix' => '</p>',
    '#ajax' => array(
      'callback' => 'bp_filters_header_group_js',
      'wrapper' => 'bp-filters-header-group',
      'method' => 'replace',
      'effect' => 'none',
      'progress' => array('type' => 'none'),
    ),
  );
  $form['brand'] = array(
    '#type' => 'select',
    '#options' => $brand_options,
    '#prefix' => '<span id="bp-filters-header-group"><p id="bp-filters-header-brand">',
    '#suffix' => '</p>',
    '#disabled' => $brand_disabled,
    '#ajax' => array(
      'callback' => 'bp_filters_header_group2_js',
      'wrapper' => 'bp-filters-header-group2',
      'method' => 'replace',
      'effect' => 'none',
      'progress' => array('type' => 'none'),
    ),
  );
  $form['series'] = array(
    '#type' => 'select',
    '#options' => _bp_filter_get_series($type_tid, $brand_tid),
    '#prefix' => '<span id="bp-filters-header-group2"><p id="bp-filters-header-series">',
    '#suffix' => '</p>',
    '#disabled' => $series_disabled,
    '#ajax' => array(
      'callback' => 'bp_filters_header_submit_js',
      'wrapper' => 'bp-filters-header-submit',
      'method' => 'replace',
      'effect' => 'none',
      'progress' => array('type' => 'none'),
    ),
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#attributes' => array('class' => $submit_classes),
    '#value' => '',
    '#prefix' => '<p id="bp-filters-header-submit">',
    '#suffix' => '</p></span></span>',
    '#disabled' => $submit_disabled,
  );

I'm using standart D7 Ajax API to load/change form elements.

So what i'm trying to get:

Make 3 dependent select boxes. I.e. when a value from the first one is selected, the second and third change. The third select box depends on the second one.

Everything work ok in all browsers except Opera for Win [no problem with Linux] (I'm using v11.51).
When you select an item (in Opera) from the select box, it doesn't collapse though ajax event is fired and data is loaded successfully.

Is there any way to collapse the select box after the event if fired?

Here is the php code for the form:

  $form['type'] = array(
    '#type' => 'select',
    '#options' => _bp_filter_get_types(),
    '#attributes' => array('onReady' => "alert('Hello!');return false;"),
    '#prefix' => '<p>',
    '#suffix' => '</p>',
    '#ajax' => array(
      'callback' => 'bp_filters_header_group_js',
      'wrapper' => 'bp-filters-header-group',
      'method' => 'replace',
      'effect' => 'none',
      'progress' => array('type' => 'none'),
    ),
  );
  $form['brand'] = array(
    '#type' => 'select',
    '#options' => $brand_options,
    '#prefix' => '<span id="bp-filters-header-group"><p id="bp-filters-header-brand">',
    '#suffix' => '</p>',
    '#disabled' => $brand_disabled,
    '#ajax' => array(
      'callback' => 'bp_filters_header_group2_js',
      'wrapper' => 'bp-filters-header-group2',
      'method' => 'replace',
      'effect' => 'none',
      'progress' => array('type' => 'none'),
    ),
  );
  $form['series'] = array(
    '#type' => 'select',
    '#options' => _bp_filter_get_series($type_tid, $brand_tid),
    '#prefix' => '<span id="bp-filters-header-group2"><p id="bp-filters-header-series">',
    '#suffix' => '</p>',
    '#disabled' => $series_disabled,
    '#ajax' => array(
      'callback' => 'bp_filters_header_submit_js',
      'wrapper' => 'bp-filters-header-submit',
      'method' => 'replace',
      'effect' => 'none',
      'progress' => array('type' => 'none'),
    ),
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#attributes' => array('class' => $submit_classes),
    '#value' => '',
    '#prefix' => '<p id="bp-filters-header-submit">',
    '#suffix' => '</p></span></span>',
    '#disabled' => $submit_disabled,
  );

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

这个俗人 2024-12-16 20:45:14

Opera 从 Windows 版本 v10 开始就遇到了这个错误。我花了3个小时来解决这个问题,但没有得到任何结果。我认为没有明智的方法来赢得它 =(

Opera has got this bug starting with v10 for Windows. I spent 3 hours struggled this and gave the nothing result. I think there aren't sane ways to win it =(

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文