Fresh drupal install for testing this.
I have a very simple page view with an exposed filter for search terms with ajax enabled.
when I create a template file for the exposed filter and move the reset button above the submit button the reset button now throws an ajax error.
why does changing the button order cause such problems and has any found a fix/workaround for this issue?

original:

<div class="views-exposed-widget views-submit-button">
  <?php print $button; ?>
</div>
<?php if (!empty($reset_button)): ?>
  <div class="views-exposed-widget views-reset-button">
    <?php print $reset_button; ?>
  </div>
<?php endif; ?>

changed:

<?php if (!empty($reset_button)): ?>
  <div class="views-exposed-widget views-reset-button">
    <?php print $reset_button; ?>
  </div>
<?php endif; ?>
<div class="views-exposed-widget views-submit-button">
  <?php print $button; ?>
</div>

and here is the ajax error:

An AJAX HTTP error occurred.
HTTP Result Code: 200
Debugging information follows.
Path: /drupal_sandbox/views/ajax
StatusText: OK
ResponseText: 
Site-Install
@import url("http://localhost/drupal_sandbox/modules/system/system.base.css?ob1ie5");
@import url("http://localhost/drupal_sandbox/modules/system/system.menus.css?ob1ie5");
@import url("http://localhost/drupal_sandbox/modules/system/system.messages.css?ob1ie5");
@import url("http://localhost/drupal_sandbox/modules/system/system.theme.css?ob1ie5");
@import url("http://localhost/drupal_sandbox/modules/comment/comment.css?ob1ie5");
@import url("http://localhost/drupal_sandbox/modules/field/theme/field.css?ob1ie5");
@import url("http://localhost/drupal_sandbox/modules/node/node.css?ob1ie5");
@import url("http://localhost/drupal_sandbox/modules/search/search.css?ob1ie5");
@import url("http://localhost/drupal_sandbox/modules/user/user.css?ob1ie5");
@import url("http://localhost/drupal_sandbox/sites/all/modules/views/css/views.css?ob1ie5");
@import url("http://localhost/drupal_sandbox/sites/all/modules/ctools/css/ctools.css?ob1ie5");
@import url("http://localhost/drupal_sandbox/sites/all/modules/panels/css/panels.css?ob1ie5");
@import url("http://localhost/drupal_sandbox/sites/all/themes/boilerplate/css/compiled/style.css?ob1ie5");
@import url("http://localhost/drupal_sandbox/sites/all/themes/boilerplate/css/compiled/ie8.css?ob1ie5");
@import url("http://localhost/drupal_sandbox/sites/all/themes/boilerplate/css/compiled/ie7.css?ob1ie5");
@import url("http://localhost/drupal_sandbox/sites/all/themes/boilerplate/css/compiled/ie6.css?ob1ie5");
You are using an outdated browser. Please upgrade your browser or activate Google Chrome Frame to improve your experience.
Jump to Navigation
Site-Install
Home
hello
Type          
- Any -ArticleBasic page
Search Terms          
test smurf page    
test page 2    
test page 1    
User login
Username *
Password *
Create new account
Request new password
Powered by Drupal
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dave.erwin created an issue. See original summary.

dave.erwin’s picture

Issue summary: View changes
dave.erwin’s picture

Issue summary: View changes
dave.erwin’s picture

I'm looking at the code in ajax_view.js

var button = $('input[type=submit], button[type=submit], input[type=image]', this.$exposed_form);
  button = button[0];

it's setting var button to the first submit in the exposed form, which is the reset button if it's moved ahead of the submit.
I realize it's bad practice to move the reset before the submit due to browser behavior when hitting enter key, wondering if a better solution would be to change the type of the reset from a submit to type="reset"?

Anonymous’s picture

Version: 7.x-3.14 » 7.x-3.x-dev
Status: Active » Needs review
FileSize
658 bytes

I created a patch to not include reset buttons when attaching exposed form ajax.

Anonymous’s picture

Looks like this is a potential duplicate of https://www.drupal.org/node/1109980

Chris Matthews’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll

The 2 year old patch in #5 to ajax_view.js does not apply to the latest views 7.x-3.x-dev.

Checking patch js/ajax_view.js...
error: while searching for:
};

Drupal.views.ajaxView.prototype.attachExposedFormAjax = function() {
  var button = $('input[type=submit], button[type=submit], input[type=image]', this.$exposed_form);
  button = button[0];

  this.exposedFormAjax = new Drupal.ajax($(button).attr('id'), button, this.element_settings);

error: patch failed: js/ajax_view.js:83
error: js/ajax_view.js: patch does not apply
Andrew Answer’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
FileSize
630 bytes

Patch rerolled.