Using ajax only the first tab is loaded. Clicking on the other tabs there is a text saying content is loading, but then replaced by nothing. Enabling "Use Ajax" within each view does not change it unlike same issue for D7.

Issue fork quicktabs-2926105

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Waen created an issue. See original summary.

socialnicheguru’s picture

I get this . In addition I get the following JS errors:

VM39609:9 Uncaught ReferenceError: TL is not defined
    at <anonymous>:9:29
    at Array.forEach (<anonymous>)
    at <anonymous>:7:29
    at <anonymous>:13:3
    at p (jquery.min.js?v=3.2.1:2)
    at Function.globalEval (jquery.min.js?v=3.2.1:2)
    at text script (jquery.min.js?v=3.2.1:4)
    at Qb (jquery.min.js?v=3.2.1:4)
    at A (jquery.min.js?v=3.2.1:4)
    at XMLHttpRequest.<anonymous> (jquery.min.js?v=3.2.1:4)
(anonymous) @ VM39609:9
(anonymous) @ VM39609:7
(anonymous) @ VM39609:13
p @ jquery.min.js?v=3.2.1:2
globalEval @ jquery.min.js?v=3.2.1:2
text script @ jquery.min.js?v=3.2.1:4
Qb @ jquery.min.js?v=3.2.1:4
A @ jquery.min.js?v=3.2.1:4
(anonymous) @ jquery.min.js?v=3.2.1:4
(anonymous) @ VM39435:1
send @ jquery.min.js?v=3.2.1:4
ajax @ jquery.min.js?v=3.2.1:4
r._evalUrl @ jquery.min.js?v=3.2.1:4
Ja @ jquery.min.js?v=3.2.1:3
append @ jquery.min.js?v=3.2.1:3
insert @ ajax.js?v=8.4.4:498
Drupal.Ajax.success @ ajax.js?p2tosc:155
bigPipeProcessPlaceholderReplacement @ big_pipe.js?v=8.4.4:26
each @ jquery.min.js?v=3.2.1:2
each @ jquery.min.js?v=3.2.1:2
bigPipeProcessDocument @ big_pipe.js?v=8.4.4:36
(anonymous) @ big_pipe.js?v=8.4.4:50
setTimeout (async)
bigPipeProcess @ big_pipe.js?v=8.4.4:49
(anonymous) @ big_pipe.js?v=8.4.4:60
(anonymous) @ big_pipe.js?v=8.4.4:68

VM39435:1 POST https://mysite.com/quicktabs/ajax/sng_event_group/1?_wrapper_format=drupal_ajax 500 (500 Service unavailable (with message))
(anonymous) @ VM39435:1
send @ jquery.min.js?v=3.2.1:4
ajax @ jquery.min.js?v=3.2.1:4
Drupal.Ajax.eventResponse @ VM39604:111
(anonymous) @ ajax.js?v=8.4.4:255
dispatch @ jquery.min.js?v=3.2.1:3
q.handle @ jquery.min.js?v=3.2.1:3
ajax.js?v=8.4.4:472 Uncaught Drupal.AjaxError {message: "↵An AJAX HTTP error occurred.↵HTTP Result Code: 50…ered an unexpected error. Please try again later.", name: "AjaxError"}

In my logs I get the following quicktabs error:

Uncaught PHP Exception LogicException: "The render array has not yet been rendered, hence not all attachments have been collected yet." at drupal-8.4.4/html/core/lib/Drupal/Core/Asset/AttachedAssets.php line 36
bala.addweb’s picture

StatusFileSize
new28.37 KB
new35.24 KB

I do the same but it works fine for me. PFA screenshots.

andkar’s picture

I experience the same problem with views that take a argument.
For me it works to load views with ajax if the view doesn’t use arguments.

marassa’s picture

StatusFileSize
new12.48 KB

Please try the following:
1. Install the patch from here: https://www.drupal.org/project/quicktabs/issues/2873253
2. Make sure you specify your arguments in the quicktab setup (see screenshot). Keep in mind that the first argument (like '333' in '/node/333') will be %2 (don't ask me why:).
3. Flush the cache.

shelane’s picture

firnas’s picture

When the ajax request for loading a new tab is made, I can notice the following error in the db log:

Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException: You have requested a non-existent service "path.alias_manager". Did you mean this: "path_alias.manager"? in Drupal\Component\DependencyInjection\Container->get() (line 151 of /opt/drupal/web/core/lib/Drupal/Component/DependencyInjection/Container.php).

I noticed this is mentioned in (quicktabs/src/Plugin/TabType/ViewContent.php) line 89

firnas’s picture

FYI..I was using 8.x-3.0-alpha4 when I posted my earlier comment .. now I can see this is resolved in dev version 8.x-3.x-dev.. and it works fine for me now.

meerachandran’s picture

I am using the latest dev version, and my views have contextual filter, and turned ajax on. The seond view block is not loading when using ajax inside quicktab.

jukka792’s picture

I have also the latest dev, and the quick tabs are only showing the first tab when ajax is enabled.

When the ajax is disabled in the quictabs settings, the tabs are showing content.

All of the tabs have views with same argument, and all views have ajax enabled.

In the html source I see only "Loading content ..."

I have content: /group/33/ so the argument is %2, but this argument is not needed when ajax is not used.

vasiliyrepin’s picture

I have at the same problem.
I have also Version:
8.x-3.x-dev, and the quick tabs are only showing the first tab when ajax is enabled.

When the ajax is disabled in the quictabs settings, the tabs are showing content.

All of the tabs have views with same argument, and all views have ajax enabled. And I made this Views as block and choosen in QT setting without arguments - There are no changes, ajax not works.

I have content: /taxonomy/term/1/ so the argument is %3, but this argument is not needed when ajax is not used.
And my View has contextual filter "Content has Taxonomy Term id from url"! Thanks to my View I have content category system,
/taxonomy/term/1/ will contain Quick Tabs and QT must displays some entities.
It's basic functionality in my opinion, but ajax not works(((
P.S. Thank you very much for this module!

jukka792’s picture

I have still the same problem, but now I found out that it depends what kind of views argument you are using.
If the argument is for example "get User ID from the logged in user", then the quictabs is working with ajax, all the tabs are loading.

But when the argument in the views is "take raw value from URL" and putting anything to quicktabs arguments like %1 or arg1 it
does not load the second tab. So in my case the argument is the User ID from the URL, not the logged in user ID " /user/34 "
So again, if I change the views getting the ID from logged in user, the second tab is shown.

lubwn’s picture

Yeah I can confirm this is still an issue. Solved it by disabling ajax for quick tabs so my views can take arguments from URL. Kind of a bummer but it works.

plague’s picture

StatusFileSize
new43.1 KB

I faced the same problem with static arguments in quicktabs. It depends on setting of Contextual Filter in Views Display. Try to change option "When the filter value is NOT available" on "Display all results for the specified field".

It appears because this line https://git.drupalcode.org/project/quicktabs/-/blob/8.x-3.x/src/Plugin/T... return empty result when you chose not a "Display all results for the specified field".

views settings

smustgrave’s picture

Version: 8.x-3.x-dev » 4.0.x-dev
smustgrave’s picture

Status: Active » Postponed (maintainer needs more info)

Wonder if this is still an issue? Not seeing it in latest version.

dcam’s picture

@smustgrave I'm experiencing the issue with quicktabs version 4.0.1.

I have a set of tabs. Each tab contains a view. All views have a contextual filter on the content ID from the URL.

If I set the tabs to load all tabs on page view, then there's no problem.

If I set the tabs to only load the first tab on page view, then click on another tab, no content is loaded. I can see the "Loading content..." message pop up briefly, but it's replaced with nothing. The tabpage DIV remains empty.

Supplying the tab with an argument doesn't fix the problem. I wondered if that's because I have path aliases set for all these pages, but it doesn't sound like it fixes the problem for unaliased pages.

For a while it didn't bother me because I set the tabs to all load with the page. But we've been experiencing performance problems with this site, so I tried to set them to load with AJAX. That led me here.

thatguy’s picture

I couldn't figure out the exact issue but seemed to be something with setting the arguments. I dropped the use of views_get_view_result-function and just setArguments and ran other view functions in the ViewContent class render-function and seemed to fix the issue for me. For Quicktabs configuration I used %2 as the arguments for my "Content: ID" contextual filter with "Content ID from url" as the default value.

thatguy’s picture

Status: Postponed (maintainer needs more info) » Needs review
smustgrave’s picture

Status: Needs review » Needs work

Thanks but issues should be in MRs not patches

ramil g made their first commit to this issue’s fork.

ramil g’s picture

Status: Needs work » Needs review

I tested patch #18 from thatguy and it seems to work. I created an mr for it. I'm changing that status to Needs Review.

Edit: I did not test it properly so I'm going to take what I said back. I will confirm whether or not it works after I do a better job of testing.

ramil g’s picture

After further review, it seems that #18 doesn't in fact solve the issue.

joelpittet made their first commit to this issue’s fork.

joelpittet’s picture

A note on the non-test changes, since the thread already covers the symptom.

The old code recovered the source page path from the referrer, but only used it for Quick Tabs' own %1, %2 replacement. That handles static args but misses Views contextual defaults like "Raw value from URL," which read from the View's request, not the Quick Tabs config. During an AJAX callback that request still points at /quicktabs/ajax/..., so they resolve against the wrong path and the tab comes back empty.

The fix hands the View a request that matches the source page:

if ($this->isAjaxRequest()) {
  $view_request = Request::create($current_path);
  $request = $this->requestStack->getCurrentRequest();
  if ($request?->hasSession()) {
    $view_request->setSession($request->getSession());
  }
  $view->setRequest($view_request);
}

The session is copied because the render path can expect one. Same idea as core Views AJAX, which carries view_path through the request and restores it before rendering.

The rest is tidying: getSourcePath() and isAjaxRequest() just pull existing logic into named helpers, and the instanceof ViewExecutable check moved ahead of access() so we don't call access() on a failed Views::getView().

joelpittet’s picture

One thing I'd like input on before building it.

This fix leans on the referrer, because Quick Tabs AJAX links carry no explicit source path. A sturdier approach would pass that path through drupalSettings or AJAX link metadata, the way core Views handles view_path. That's a bigger change, so I kept it out of this MR for now.

Before I take it on: does relying on the referrer break anything in your setup, or is the metadata route worth the extra work? Given the age of this one, I'd rather hear from you all than guess.

AI disclosure: used AI to do some heavy lifting, especially around the tests. I read and understand the changes and steered it in a few different directions before landing on the MR changes described in comment #26.

joelpittet’s picture

Status: Needs review » Fixed

If anybody is interested in the view_path solution let me know. We can spin up a separate issue targetting that.

Thanks everyone for the reports, debugging notes, patches, and testing over the years. The fix is merged now; it should handle AJAX-loaded Quick Tabs views that rely on URL-derived contextual filters. Special thanks to the folks who narrowed this down to Views arguments/contextual filters and helped test earlier approaches.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

  • joelpittet committed 6b825d95 on 4.0.x
    fix: #2926105 Tabs fail to load when using Ajax
    
    By: venge
    By: andkar
    By...
joelpittet’s picture

ramil g, showed me the not working state, when the arguments are not filled. I will create a follow-up #3605596: Quick Tabs AJAX does not load Views using current node contextual filter

Status: Fixed » Closed (fixed)

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