I have a view that I need to use the display type "block". It needs to have an exposed filter.

There is an issue when a user uses the exposed filter. They view results are not updated within that block. Rather the user is redirected to another page. The arguments for this exposed filter are added to the URL in this redirect. Its like it is not using AJAX.

For example:
Consider a view displayed as a block at:
/my-page-with-blocks
I use the exposed filter called "category" and set it to "foo".
If the view does not have a page display defined then I am redirected to:
/?category=foo
If the view does have a page display defined I am redirected to it:
/my-page-that-is-a-view/?category=foo

Both of these are wrong. I should have stayed on /my-page-with-blocks and the view should have been updated with AJAX.

The "Use AJAX" option of the view is enabled.
I do not see any Javascript errors in the console.

This seems similar to:
http://drupal.org/node/1153780
Though that resolution had to do with how to embed the view and its solution was committed before my version of views.

http://drupal.org/node/1123300
Though I am not using and image for the form submit. It is the standard input submit element.

I would appreciate any help. Here is an export of my view.
http://pastebin.com/btY8EeQc

I am using
Drupal Core 7.2
Views 7.x-3.x-dev (2011-Jul-17)
Chaos tool suite 7.x-1.x-dev (2011-Jul-17)

Comments

merlinofchaos’s picture

This probably means javascript is somehow crashing. or somehow failing to apply to the button.

1) Do you have a theme changing the nature of the submit button?
2) Can you check your javascript logs and see if there's a js error in there?

maestrojed’s picture

Thank you for the quick response.
1) I don't think so but to be sure I switched the theme to Bartik. The issue persists
2) I don't see anything in the javascript console. No errors or warnings. Are there other logs I should be checking? Any other debug tips?

Thanks again.
Jed

maestrojed’s picture

If it helps here is a link.

It may "appear" like it is working but that is because this page (/document-center) (which has the view as a block) redirects to the views "page" display (/product-documents). I had to set this up as a temporary work around since this is a production site. You should stay on /document-center and the results should update a la Ajax.

http://bit.ly/oFE3s7

Thanks,
maestrojed

fourmi4x’s picture

I don't know if you're using an embed, but here are two other links that might help:
- About AJax not working with an embed in a page.tpl: http://drupal.org/node/386388
- About exposed filters redirecting to the fontpage: http://drupal.org/node/525592

maestrojed’s picture

It is just a normal block added to a page. Done via the backend not embedded in the tpl. But I will scan through these and see if they shine some light on the issue.

Thank you!

hashmap’s picture

subscribe

owntheweb’s picture

subscribing

twistedindustries’s picture

I am having the same issue, everything works fine with the exposed filter is included in the view itself but if I say Exposed form in block: Yes, then no matter what it doesn't use ajax.

dawehner’s picture

Status: Active » Fixed

Okay added this links to this special blocks.

If someone is interested 44e4a37 was the commit id.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

maestrojed’s picture

Version: 7.x-3.x-dev » 7.x-3.4
Status: Closed (fixed) » Active

I hate that I am reopening this so much later but this issue still exists for me. I have updated to Views 7.x-3.4.

I will recap:

I want a view, that is an embedded block, and has exposed filters.

From my understanding ajax must be used for exposed filters + views as a block. When I turn off ajax the exposed filters disappear. So ajax is on.

If the URL for the page with the embedded view (block) is:
/foo
When I use the exposed filter I am redirected to:
/?filterName=value

Two things seem wrong here:
1) I have been redirected away from the page with the view and to the home page.
Seems like it should be:
/foo?filterName=value
2) Why am I being redirected, why is the page reloading, if I am using ajax?

Here is a live example http://hi5fri.com/PFw4Cv

I didn't see anything like this in the issue queue so maybe I am doing something wrong.

There are other contributed modules used on this site. Most are standard. I do feel like mentioning we use the Domain Access module. This module is big, not used a widely and does URL rewriting which is why I mention it.
http://drupal.org/project/domain

Thanks for any help!
-maestrojed

maestrojed’s picture

The issue focuses around the ajax not working. If ajax was working the form would not be redirecting/reloading a page at all.

This also seems to be a module conflict. Using the same version of Views on a striped down version of the site and all this works fine. So I guess the views community may call this a module conflict and want to close the ticket.

My last question:
Are there any tips for debugging why ajax is not working? Nothing shows in my console.

Taxoman’s picture

@maestrojed: between the fixed state last year, and now, did you use views 3.3 without this problem?
If not, then this issue should be file against 3.x-dev, not 3.4...

anniegreens’s picture

I am also experiencing this issue with 7.x-3.5, but only with Internet Explorer. Hitting 'enter' to submit the exposed filter on a view block with AJAX enabled, redirects you to the page display of the view.

anniegreens’s picture

Version: 7.x-3.4 » 7.x-3.5

Updating to 7.x-3.5.

jhuon’s picture

StatusFileSize
new36.24 KB

I also get this issue with Views 7.x-3.5. My view block have an exposed filter with ajax on. I'm redirected to the front page when I submit the form. I'm redirected to the page if my views have one. No warnings, no javascript errors. I get this issue with Chrome, Firefox, Safari, Opera.

owntheweb’s picture

Hello,
Views: 7.x-3.5 and Views: 7.x-dev (using this currently)
Drupal core 7.18

I have the same challenges. Check out the live test page at:
http://www.nationalspacesymposium.org/test-agenda (views block in a page node, placed from blocks admin page)

When selecting/deselecting a checkbox (or selecting an option before I installed Better Views Filters module), you'll get redirected to a page view display that was created at:
http://www.nationalspacesymposium.org/test-agenda2

Observations that may help narrow things down?:

  • If I don't create a page or a feed view with only block display(s) created, what should be ajax requests results in redirects to the home page looking like this (no errors, no console messages with redirect):
    /?field_event_categories_value[]=General+Program&field_event_categories_value[]=Cyber+1.3&...
  • If I create a feed display in my view, all block filter interaction results in redirects to the feed URL (odd):
    /myfeedurl?field_event_categories_value[]=General+Program&field_event_categories_value[]=Cyber+1.3&...
  • If I remove the feed display and add a page display, all block filter interaction results in redirects to the page URL (including requests made from the page display itself):
    /test-agenda2?field_event_categories_value[]=General+Program&field_event_categories_value[]=Cyber+1.3&...
  • My exposed filters are using auto-submit. Adding an "Apply" button and various other options doesn't seem to make a difference.
  • Exposed filters DO work properly in the views edit page preview area.
  • Disabling the following modules does not make a difference:
    -jQuery Update
    -Better Views Filters
    -... I'll try disabling everything locally shortly

I truly appreciate the support in advance and will continue to troubleshoot on my end.

owntheweb’s picture

After stripping everything down, removing almost every module, I'm guessing this is Theme related in my case. It is working now in Bartik and Seven for me, but not my theme which expands/revises the Twitter Bootstrap theme. I'll try stripping out or revising some javascript to start.

UPDATE: RESOLVED (for me anyway)

The issue in my case was the parent Twitter Bootstrap theme I was working with. Specifically, the twitter_bootstrap_button() function, with the issue going away after I commented that out and cleared the cache. Updates will be added to the live version of site after further testing.

Salih’s picture

I get little different issue with Ajax when it turned on to show filter exposed in block form. Here is the link http://www.threeyem.com/page/compatible-toner-cartridges you can see the site & views jump menu with exposed filter. I am trying to display a brand names as filter exposed for user, so jump menu shows only the list of printer according to user selection and GO the node.
Problem is:When I set Use Ajax to YES to show exposed filter in block form, it return error as show in attachment.
Quick help appreciated.
Thanks
Salih
www.threeyem.com

scottAtRoot802’s picture

I am have a similar issue, however only when I use the return key to submit the form. Clicking on the submit button works as expected. It seems the views jquery isn't capturing the return key. I recently updated to Views 7.x-3.6 but my issue has been the same for both Views 7.x-3.5 and 7.x-3.6.

My view block has an exposed filter with ajax on. I'm redirected to the front page when I submit the form. I'm getting no warnings or javascript errors.

micromegas’s picture

I am using Drupal 7.22 with Views 7.x-3.7.

In my case, I have a block with an exposed text filter for the 'title' field, with autosubmit turned on. I've tested this on multiple themes with the same result.

When a user types something in the text box, and presses 'enter' before the autosubmit completes, it causes the entire page to refresh with a contextual argument in the URL, such as domain.com/?title=abc

When I turn 'autosubmit' off, hitting 'enter' causes the block to do an AJAX refresh with the content as normal.

EDIT: My particular issue appears only when I use the Safari browser. Therefore, I opened issue https://drupal.org/node/2014953 because I suspect this is a CTools autosubmit issue.

supradhan’s picture

Same issue here when using Enter. I am using views 3.7 and drupal 7.22

andrés chandía’s picture

More or less the same is happening to me:

I've created a blockview with an autocomplete exposed filter and if I activate the autosubmit, hidding the apply button, the moment I start to write in the text box the candidates appears just an instant and then go away not letting me choose, so as result the border of the text box turns red, as it was an error. Actually, if I go to the view editting page and I try the filter from there, as soon as I put a letter I got this:

An AJAX HTTP request terminated abnormally.
Debugging information follows.
Path: http://parles.upf.edu/en/admin/views/ajax/autocomplete/taxonomy/14
StatusText:
ResponseText:
ReadyState: 4

And then a new page with the filter saying this: Unable to find term: f (the letter I just reached to type)
May be I'm doing something wrong?

Thanks for your help.

mahipal46’s picture

One more thing for people using "Content pane" display in views. You need to set "Use Panel path: Yes" in order to fix this issue. or in your view Use AJAX: Yes for this panel pane it will works fine.

silentbob’s picture

I am using Content Pane in as a Display Suite Field of User. My Exposed Filters are in a block on the right side.
I set "Use Panel Path :Yes" and "Ajax: Yes". Applying Filters works perfectly fine. But resetting them redirects me to the frontpage too.

andrés chandía’s picture

Well, I had the "Use AJAX: Yes", but the Use "Panel path: No", I changed to yes but without success, the error at the view editting page appears just for an instant, but the red marc did not appear any longer at the block, once you introduce a letter in the text box it let you see the available options for just a little while, not letting you choose, and then it shows you only the letter you've reached to type, and that's it.....

silentbob’s picture

subscribe

Marko B’s picture

Similar problem here https://www.drupal.org/node/525592 try the solution.

mrcdrx’s picture

subscribing, having the same issue.

Leeteq’s picture

Version: 7.x-3.5 » 7.x-3.x-dev
Chris Gillis’s picture

I have a view with an exposed AJAX form using BEF in a block. Everything was working fine until I upgraded from views 7.x-3.8 to views 7.x-3.10. Now, instead of the filter filtering the view, it redirects to the homepage. I wonder if this is related to the "Open redirect vulnerability" in https://www.drupal.org/node/2424403

Downgrading back to views 7.x-3.8 resolves the issue.

czigor’s picture

I have the same issue here as in #31. It works with 3.8 but not with 3.10.

valentin schmid’s picture

Same issue for me. Worked with views 3.8, failed with views 3.10.

The commit http://cgit.drupalcode.org/views/commit/?id=710a536 causes this issue.

Undoing this commit helped in one of my projects.

kumkum29’s picture

Hello,

same problem for me. Now the views redirect to the homepage if we use a filter....no good.
My views are displayed in my template by a views_embed_view($viewName, $viewDisplay, $viewArgs). For each view I use a custom template (views-view-field--... / master template of the view). If I don't use this template I haven't problem. Strange...

czigor’s picture

I can confirm that after undoing http://cgit.drupalcode.org/views/commit/?id=710a536 my exposed filter works.

czigor’s picture

Anyone knows if the reason behind http://cgit.drupalcode.org/views/commit/?id=710a536 was that we cannot rely on the id because it can change?

kumkum29’s picture

Maintainers are going to change this code (by the old) in the next version of the module?
If no, the problem seems persist on the futures versions.
Any information is good to take.
Thanks.

kumkum29’s picture

Priority: Normal » Major
czigor’s picture

Status: Active » Needs review
StatusFileSize
new502 bytes

http://cgit.drupalcode.org/views/commit/?id=710a536 makes a .view-filters wrapper necessary around the exposed form filter. Custom views templates might not have this wrapper and this can cause the bug.

Also, children() is too strict for some templates, we should use find().

I can accept having this wrapper but we still want to change the .children().children to .find() to allow more flexibility in the template.

tl;dr
To fix:
1. Apply patch
2. Add a .view-filters wrapper around your exposed filters.

kumkum29’s picture

Hello czigor,

I have tried your patch and it's ok if I submit a exposed filter we stay on the same page.
But, in my page, i have another javascript (image load, fade-in...) and the image is reloaded each time that i apply the filters.
(I have only apply the patch not the #2 point)

Mike Dodd’s picture

Great patch, thank you

spfaffly’s picture

#39 works beautifully.

Thanks czigor for pointing me in the right direction.

mustanggb’s picture

Status: Needs review » Needs work

Doesn't work when exposed form is in a block.

ParisLiakos’s picture

mustanggb’s picture

Status: Needs work » Closed (duplicate)

There are so many issues in this thread, most of them seem to be symptoms rather than solutions.

The most recent posts don't directly relate to the OP anymore and I agree are also duplicate of #2425099: Exposed form in block with ajax no longer works.

Due to this thread being all over the place and #2425099 being more on point I say lets move over there and combine efforts.