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!

Comments

eugene.ilyin’s picture

Hello. Seems I catched the reason of problem, but it's not easy to solve. I will try to do it in few days.

eugene.ilyin’s picture

Status: Active » Fixed

Your problem solved in version 7.x-1.3. Enjoy it! =)

gabriel.camby’s picture

Just 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...

eugene.ilyin’s picture

I think that for it you should write separate widget for facets. You can see examples of simple widgets in module ajax_facets.

gabriel.camby’s picture

Yes, I think so. Thank you!

Status: Fixed » Closed (fixed)

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

Anonymous’s picture

Issue summary: View changes

Typo

svipsa’s picture

Issue summary: View changes

The same issue for 7.x-3.1 version. Cant use exposed filters when ajax facet was seleted

reptilex’s picture

I 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.

Tonyhawk127’s picture

Status: Closed (fixed) » Needs work

Same 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! (:

eugene.ilyin’s picture

Status: Needs work » Postponed (maintainer needs more info)

Sorry, 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?

Tonyhawk127’s picture

Thanks 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? ;)

eugene.ilyin’s picture

Sorry, 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?

Tonyhawk127’s picture

StatusFileSize
new1.79 MB

I 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! :)

Tonyhawk127’s picture

Update:
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.

eugene.ilyin’s picture

Yes, 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.

Tonyhawk127’s picture

I 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... :)

  • eugene.ilyin committed 4b1b897 on 7.x-3.x
    Issue #2034029 by Tonyhawk127: Views AJAX exposed filters are disabled...
  • eugene.ilyin committed e1bea59 on 7.x-3.x
    Issue #2034029: Views AJAX exposed filters are disabled after a facet...
eugene.ilyin’s picture

Status: Postponed (maintainer needs more info) » Needs review

Corrected. Can somebody check it?

maximpodorov’s picture

Status: Needs review » Needs work

Incorrect 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.

eugene.ilyin’s picture

Status: Needs work » Postponed (maintainer needs more info)

I cannot reproduce this problem, please provide more info.

maximpodorov’s picture

Status: Postponed (maintainer needs more info) » Needs work

I 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.

maximpodorov’s picture

This is the quick and dirty fix which checks view existence. The real solution is not to add ajax_facets.js on any search page.

maximpodorov’s picture

Version: 7.x-1.x-dev » 7.x-3.x-dev
Status: Needs work » Needs review
eugene.ilyin’s picture

Status: Needs review » Postponed (maintainer needs more info)

Sounds 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.

maximpodorov’s picture

Maybe 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.

eugene.ilyin’s picture

I 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.

maximpodorov’s picture

OK, 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).

eugene.ilyin’s picture

Status: Postponed (maintainer needs more info) » Fixed

@maximpodorov, btw I think that your problem isn't related with this issue. Please report it separately.

maximpodorov’s picture

The problem is caused by the commit mentioned in this issue:
http://cgit.drupalcode.org/ajax_facets/commit/?id=e1bea59

eugene.ilyin’s picture

I 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.

maximpodorov’s picture

The 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.

maximpodorov’s picture

Moving the line
ajax_facets_add_ajax_js($this->facet);
from init() to execute() solves the problem.

Tonyhawk127’s picture

Just to confirm: Checked, works now perfect for me. Thanks!

maximpodorov’s picture

Status: Fixed » Needs review
StatusFileSize
new3.98 KB
eugene.ilyin’s picture

Why does we need this PoC?

+    var view = $('.view-id-' + view_name + '.view-display-id-' + display_name);
+    if (view.length < 1) {
+      return false;
+    }
maximpodorov’s picture

Because 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.

maximpodorov’s picture

Is it acceptable?

eugene.ilyin’s picture

Status: Needs review » Fixed

Thank you Maxim. Committed.

eugene.ilyin’s picture

eugene.ilyin’s picture

Status: Fixed » Closed (fixed)

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