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)
| Comment | File | Size | Author |
|---|---|---|---|
| #39 | views-ajax_block_exposed_filter_redirect-1222762-39.patch | 502 bytes | czigor |
| #19 | An-Ajax-HTTP-error-occured.jpg | 231.45 KB | Salih |
| #16 | views-export.txt | 36.24 KB | jhuon |
Comments
Comment #1
merlinofchaos commentedThis 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?
Comment #2
maestrojed commentedThank 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
Comment #3
maestrojed commentedIf 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
Comment #4
fourmi4x commentedI 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
Comment #5
maestrojed commentedIt 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!
Comment #6
hashmap commentedsubscribe
Comment #7
owntheweb commentedsubscribing
Comment #8
twistedindustries commentedI 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.
Comment #9
dawehnerOkay added this links to this special blocks.
If someone is interested 44e4a37 was the commit id.
Comment #11
maestrojed commentedI 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
Comment #12
maestrojed commentedThe 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.
Comment #13
Taxoman commented@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...
Comment #14
anniegreens commentedI 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.
Comment #15
anniegreens commentedUpdating to 7.x-3.5.
Comment #16
jhuon commentedI 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.
Comment #17
owntheweb commentedHello,
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?:
/?field_event_categories_value[]=General+Program&field_event_categories_value[]=Cyber+1.3&...
/myfeedurl?field_event_categories_value[]=General+Program&field_event_categories_value[]=Cyber+1.3&...
/test-agenda2?field_event_categories_value[]=General+Program&field_event_categories_value[]=Cyber+1.3&...
-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.
Comment #18
owntheweb commentedAfter 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.
Comment #19
Salih commentedI 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
Comment #20
scottAtRoot802 commentedI 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.
Comment #21
micromegas commentedI 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.
Comment #22
supradhan commentedSame issue here when using Enter. I am using views 3.7 and drupal 7.22
Comment #23
andrés chandía commentedMore 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:
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.
Comment #24
mahipal46 commentedOne 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.
Comment #25
silentbob commentedI 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.
Comment #26
andrés chandía commentedWell, 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.....
Comment #27
silentbob commentedsubscribe
Comment #28
Marko B commentedSimilar problem here https://www.drupal.org/node/525592 try the solution.
Comment #29
mrcdrx commentedsubscribing, having the same issue.
Comment #30
Leeteq commentedComment #31
Chris Gillis commentedI 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.
Comment #32
czigor commentedI have the same issue here as in #31. It works with 3.8 but not with 3.10.
Comment #33
valentin schmid commentedSame 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.
Comment #34
kumkum29 commentedHello,
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...
Comment #35
czigor commentedI can confirm that after undoing http://cgit.drupalcode.org/views/commit/?id=710a536 my exposed filter works.
Comment #36
czigor commentedAnyone 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?
Comment #37
kumkum29 commentedMaintainers 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.
Comment #38
kumkum29 commentedComment #39
czigor commentedhttp://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.
Comment #40
kumkum29 commentedHello 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)
Comment #41
Mike Dodd commentedGreat patch, thank you
Comment #42
spfaffly commented#39 works beautifully.
Thanks czigor for pointing me in the right direction.
Comment #43
mustanggb commentedDoesn't work when exposed form is in a block.
Comment #44
ParisLiakos commentedprobably duplicate of #2425099: Exposed form in block with ajax no longer works
Comment #45
mustanggb commentedThere 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.
Comment #46
donquixote commented#1809958: Views with exposed filter (ajax enabled) inside modal window (ctools) fixes the issue for me.