I'm using views with a main view and an attachment to put 2 views on a single page. Each view is in it's own Bootstrap togglable tab. Because I don't know how many people will actually switch to the non-default tab, I'd like to wait to load that view until it's needed, then load it via ajax.

Is there any way to do this within the Views UI, or is it time for custom coding? This post is kind of old, but is that the best method for executing an ajax call to render a view?

Edit: A complicating factor is that I need to include exposed filters, which also need to fetch the data via Ajax. Right now, the filters work with the second tab, but not the first. I believe this is because Quicktabs creates multiple sections with .view-dom-id-<settings.view_dom_id>, which is the selector used in Views js/ajax_view.js.

Any solutions that work with exposed filters and Ajax?

  • It would be better if you use lazy load by simply following this url -- appelsiini.net/projects/lazyload . Render two views content on a hook menu page and then using using above link for lazy loading in custom way. Dec 24, 2015 at 8:57
  • @SugandhKhanna that plugin is for images and is not specific to Drupal ajax calls at all. Can you elaborate on how it would be used in this situation?
    – nkanderson
    Dec 24, 2015 at 17:00
  • @nicolekanderson did you try my answer?
    – No Sssweat
    Dec 27, 2015 at 4:38
  • @NoSssweat I'm trying to work within the Quicktabs module and built-in Views ajax handling. I may try your code if I can't get that to work, but coding from scratch will likely involve a lot more work to get exposed filters and pagination working properly.
    – nkanderson
    Dec 28, 2015 at 20:03

2 Answers 2


U can use quicktab module for the same. Create Tab with it, and select your view which u want to use. After that there is an option to check how to load content of the tab, u can either choose to load at once, or on click of tab using ajax.

  • This module seems promising, but there are some bugs with exposed filters. @ManojBisht do you know if there's a good solution that works with exposed filters applying to both views?
    – nkanderson
    Dec 24, 2015 at 22:41

You could make the other view a page view so that they all have urls

then using the Ajax .load() function

(function ($) {

if you want an animated loading image add:

.html('<center><img src="/loading.gif"></center>').load("/view1URLgoesHERE"); 

before the .load

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.