I know this is a very bizarre feature request and it doesn't really make much sense, but it is something I currently need, and perhaps some other people might benefit from it to. I haven't dug into the code yet, but I can't see this being too hard to support.

So the options now are to either load all of the tabs when the page loads, and just toggle between them with JS, or use AJAX to fetch each tab once it's clicked. I need option #3 - to use AJAX to fetch the tabs even if they have already been fetched before.

Why? Well, actions taken on the tabs (in my case) can directly affect what is displayed on the other tab. I need the users to be able to switch between the tabs and see the changes that would result some actions/forms submitted on each of the tabs. As it stands now, they wouldn't be able to see the changes because the content isn't loaded again once it has already been.

Do you think this is a feature we could add to the module? If not, could you point me in the right direction for how to accomplish this, hopefully without having to hack the module.



mstef’s picture

Well, we can add an admin-option to enable this. Then check that setting in the JS, and if it's enabled, skip adding the class 'quicktabs-loaded'. The works but then after the second AJAX call, the tab content is appended, rather than replacing what's there. Need to figure that one out..

mstef’s picture

Can take care of that inside the ajax page callback. Use ajax_command_remove() to remove the old content first.

mstef’s picture

Status:Active» Needs review
new7.39 KB

Here's my first attempt at a patch. Seems to be working fine.

I added an ajax_always database field and admin option. If it's enabled, the quicktabs-loaded class never gets added, so it get refetched.

I had to include the qt inside the JS settings, so the JS can determine if that option was enabled for the given qt.

I also added ajax_command_remove() to remove the tab content before appending, so it gets updated and not duplicated.

Let me know what you think.

mstef’s picture

Status:Needs review» Needs work

Looks like any AJAX inside the tab content doesn't get reattached after one run - ie, the tabs have Views ajax filters and they die after one submit..

mstef’s picture

Can't figure out why the Views AJAX is screwing up.. any suggestions?

mstef’s picture

mstef’s picture

The two

if (!Drupal.settings.quicktabs[qtKey].qt.ajax_always) {

Should be

if (Drupal.settings.quicktabs[qtKey].qt.ajax_always == 0) {
mstef’s picture

mstef’s picture

Updated patch with a few tweaks.. still experiencing the Views AJAX issues though.

mstef’s picture

The error shown in #1809958: Views with exposed filter (ajax enabled) inside modal window (ctools) led me to see what's going wrong here.. The only way that error could come is if the selector returned by Views was no longer valid when Views tried to scroll back to the top.

So, when I first loaded the QT tab, the View DOM ID was: view-dom-id-003082f8146ade5688f0bad80b4a3492

After I reload that same tab via AJAX, the ID becomes: view-dom-id-1

But, Views still expects the first one to exist. Explains the JS error (from above) and why this isn't working..

How to get Views to continually return the same DOM ID; I don't know..

mstef’s picture

new97.32 KB

Here's a look at Drupal.settings in the console after reloading the tab. Explains why we're getting the DOM id issues.

mstef’s picture

Status:Needs work» Needs review

I actually think this patch is good to go. There are numerous 2 bugs in Views that are causing these errors; not Quicktabs or my patch:
#1809958: Views with exposed filter (ajax enabled) inside modal window (ctools)
#1877238: Views DOM ID and JS Settings conflict after AJAX reload

katbailey’s picture

Status:Needs review» Needs work

There seem to be some unrelated changes in the patch in #9 - can you clean it up and post a new patch with just the changes required for this issue?

I have submitted a patch for overhauling the options system which I'd like people to test out before I commit it: #1877560: Overhaul the options mechanism to make it more sane. I can then help rework your patch based on that change. The Views problem concerns me though so I will see if I can figure out a solution.

kevinorin’s picture

Currently clicking on a tab does not track it in Google Analytics. I think this request may fix that.

dead google analytics thread: http://drupal.org/node/433580

blainelang’s picture

Is there a more recent patch or an update on this feature request. It's something we were looking to solve for a project as well.

vjorden’s picture

I don't know if you figured this out...and for others who might be looking for a similar feature, I was able to get this to work by using Views Flag Refresh.

You have to set the Use Ajax to yes in the view itself. With this module, another field appears on the view admin that lets you determine when to refresh the flag.

Hope this helps!


ashutoshjha’s picture

Issue summary:View changes

Hi, You can add this script in your theme .js file and it load tabs each time without appending. In my case it works.

jQuery('.quicktabs-tabs').children('li').find('a').bind('click', function() {
cthshabel’s picture

VJ #16 awesome idea!

Thanks for commenting and leaving that info.

I think I will just use Views Flag Refresh module. This seems better for our scenario because only certain tabs need to trigger a refresh, which we can specify for individual views on only specific tabs.