Hello there,
I'm discovering a bit Facet API these days and I stumbled upon a problem related to your module (I think).
Here is the situation:
- 1 view using a Search API index (with Search API Database module)
- 1 page display with AJAX enabled
- 1 exposed filter with auto submit : Fulltext
- Facet blocks are displayed on the same page
When I filter my results using a Facet, view results are updated, alright.
The problem is happening when I want to filter again those facet filtered results with an exposed filter; I can't. That AJAX submit is not triggered.
I tried to remove the auto submit but AJAX is still gone from the submit button.
I investigated a bit and I found that the keyup, keydown, change and the other events are not attached.
The faulty line seems to be that replaceWith call in ajax_facets.js (line 245).
I tried to re-attached them without any success.
Some modules refresh views using AJAX (ala https://drupal.org/project/views_flag_refresh) but I'm not sure if it is the right way in this case.
I hope the module creator has better insight on this problem than me. :)
Thanks!
| Comment | File | Size | Author |
|---|---|---|---|
| #35 | ajax_facets-check_view_existence-2034029-35.patch | 3.98 KB | maximpodorov |
| #23 | ajax_facets-check_view_existence-2034029-23.patch | 714 bytes | maximpodorov |
| #14 | views_7.x-3.12_dev.zip | 1.79 MB | Tonyhawk127 |
Comments
Comment #1
eugene.ilyin commentedHello. Seems I catched the reason of problem, but it's not easy to solve. I will try to do it in few days.
Comment #2
eugene.ilyin commentedYour problem solved in version 7.x-1.3. Enjoy it! =)
Comment #3
gabriel.camby commentedJust tried your fix; it seems perfect on my side.
Thanks a lot, eugene.ilyin!
Now, on my way to find how I can display those taxonomy based ajax facet with a hierarchy...
Comment #4
eugene.ilyin commentedI think that for it you should write separate widget for facets. You can see examples of simple widgets in module ajax_facets.
Comment #5
gabriel.camby commentedYes, I think so. Thank you!
Comment #6.0
(not verified) commentedTypo
Comment #8
svipsa commentedThe same issue for 7.x-3.1 version. Cant use exposed filters when ajax facet was seleted
Comment #9
reptilex commentedI have the issue that the facetapi changes the dom-id of the view. I assume it is the same reason svipsa is having the issues.
In my case since I have only one view I have managed to hack it so that the dom-id is set as in the views_ajax() function of the views module. But it seems my hack is not for anyone else, since I take the dom-id from the ajax views. It would fail if the view would not be ajax or if you have more than one view with ajax.
From what I could see the function ajax_facets_refresh_facets_content() should be more like views_ajax() function in views. It should be given the the dom-id by the js script:
Drupal.behaviors.ajax_facets = {
attach: ...
And should reset it like views does.
Comment #10
Tonyhawk127 commentedSame issue here, in ajax facets 3.2 and 3.x-dev, I can't use my exposed ajax block"fulltext search filter" after selecting a facet.
Facets are still working, but I can't execute a new search, always getting this error: "Uncaught TypeError: Cannot read property 'top' of undefined"
Nevertheless: Great work, without exposed block, it's working great! (:
Comment #11
eugene.ilyin commentedSorry, but for me the exposed filter works great after I've selected some value in any ajax facet.
Maybe you have the exposed filter as separated block or other special conditions?
Comment #12
Tonyhawk127 commentedThanks for your reply. To explain it in more detail:
1. I create a View as a Block, not as a Page
2. Use this module (https://www.drupal.org/project/views_block_filter_block) to create a separate block for the search-box. (fulltext search filter)
3. Bring both together via Panels.
(Put the "Search box" into my Header-Panel, the "View Information" (=Results) into my Content-Panel)
Additionally I have "Ajax:On" in Views, to "ajaxifiy" my search-box/results.
The search is working great with the "exposed block search box", until I select a facet: After that I can't execute a new search...
Maybe now you can comprehend my problem? ;)
Comment #13
eugene.ilyin commentedSorry, but I have other problem with the same environment and settings. When I'm adding exposed form as separate block, then it doesn't work by ajax, but as a usual form. Usual form submission reloads page and reset ajax facets.
Did you have the same problem?
Comment #14
Tonyhawk127 commentedI had the same problem. Think it's a little bug in Views 3.11! It was also listed as an issue for views 3.12.In the dev-Version of Views 3.12, that I use, it's working (again) with Ajax! With Views 3.11 I had the same "failure" like you.
I put the views version I use in the attachment of this post.
Hope that its working now and you can comprehend my issue! :)
Comment #15
Tonyhawk127 commentedUpdate:
I found out that it's also a problem with the "view-dom-id", like reptilex said in post #9!
Executing new searches via ajax don't change the "view-dom-id". - When selecting a facet, the view gets a refresh and a new "view-dom-id". (See your "ajax_facets.pages.inc")
The problem: If I want to execute a new search now, the search can't find the View, because "view-dom-id" has changed. If I copy the "view-dom-id", before selecting a facet and paste it in again, after selecting a facet, it's still working.
So, is it possible to edit this behaviour in ajax_facets.pages.inc, that it's working more like views/js/ajax_view.js? (:
Think it's better, if the "view-dom-id" never changes.
Comment #16
eugene.ilyin commentedYes, you right. I've already fixed the problem with view-dom-id. But it's not pushed yet, because I found another problem. When exposed form in the separate block it resets facets after submit.
Comment #17
Tonyhawk127 commentedI also noticed that facets resets, if "view-dom-id" don't changes and I execute a new search. - But I think a "facet-reset" is better than a non-working search. :)
Nevertheless I hope you can solve this problem, too. Once again I want to thank you for your great work. Waiting for your push... :)
Comment #19
eugene.ilyin commentedCorrected. Can somebody check it?
Comment #20
maximpodorov commentedIncorrect commits. They produce JavaScript errors preventing browser to show pages correctly. I think the main problem you add your JS file on the pages which don't contain AJAX facet widgets.
Comment #21
eugene.ilyin commentedI cannot reproduce this problem, please provide more info.
Comment #22
maximpodorov commentedI have a page containing Search API based view but with no facets. This page for unknown reason loads ajax_facets.js which tries to address non-existing view on the page with "результат немного предсказуем" result.
Comment #23
maximpodorov commentedThis is the quick and dirty fix which checks view existence. The real solution is not to add ajax_facets.js on any search page.
Comment #24
maximpodorov commentedComment #25
eugene.ilyin commentedSounds strange, because ajax_facets.js is added only when one of widgets of module ajax_facets is initialized. Maybe you have some code which renders facets, but doesn't display them?
Can you provide step by step instruction, how can I reproduce the bug? Or maybe you can tell me the address of your page where this bug is appears? I can try to understand the reasons of this problem.
Comment #26
maximpodorov commentedMaybe this can help: my page contains facet pane which uses non-ajax facet widget. When I disable this pane, everything is OK. When I enable this pane, ajax_facets.js is loaded on this page.
Comment #27
eugene.ilyin commentedI tried to use page with facet "links" and ajax_facets.js isn't loaded on my page. I propose to you put breakpoint into function ajax_facets_add_ajax_js() and check what's the reason of call of this function.
Comment #28
maximpodorov commentedOK, I'll do this. But even if the root of the problem is somewhere else, you can't rely the contents of Drupal.settings. I suggest to check things before using them (as I did in the patch).
Comment #29
eugene.ilyin commented@maximpodorov, btw I think that your problem isn't related with this issue. Please report it separately.
Comment #30
maximpodorov commentedThe problem is caused by the commit mentioned in this issue:
http://cgit.drupalcode.org/ajax_facets/commit/?id=e1bea59
Comment #31
eugene.ilyin commentedI understand but I need more details to help you. Better if you can provide details of your problem in soon time because right now I have full context of this issue. Later it will be more difficult. I need step by step instructions, how this problem happens.
Comment #32
maximpodorov commentedThe source of the problem is FacetAPI initializes all enabled facets even those which are not used on the page if any facet is used on the page. So widget's init() method is called for widgets configured for all enabled facets, and you attach JS files there.
Comment #33
maximpodorov commentedMoving the line
ajax_facets_add_ajax_js($this->facet);
from init() to execute() solves the problem.
Comment #34
Tonyhawk127 commentedJust to confirm: Checked, works now perfect for me. Thanks!
Comment #35
maximpodorov commentedComment #36
eugene.ilyin commentedWhy does we need this PoC?
Comment #37
maximpodorov commentedBecause you should not expect that Drupal.settings always fit the current DOM tree. The real example - AJAX loading of pages which can change DOM tree dramatically but many parts of Drupal.settings remain. So you should always check needed DOM elements existence.
Comment #38
maximpodorov commentedIs it acceptable?
Comment #40
eugene.ilyin commentedThank you Maxim. Committed.
Comment #41
eugene.ilyin commentedComment #42
eugene.ilyin commented