Demo

A very simple module to load views either by click of a button/anchor or on page load.

Features

  • Load any Ajax view anywhere on the page via trigger or on page load
  • Respects Views permissions
  • Supports Filters
  • Supports Sorting

Installation

Consult https://www.drupal.org/docs/8/extending-drupal-8/installing-contributed-...
to see how to install and manage modules in Drupal 8.

Usage

First make sure the view you are wanting to load has "Use Ajax" set to Yes, without that this will not work.

You can load views either via a triggering element or just on page load using data attributes. The minimum requirement is to include the view id, view display.

Example: Trigger

The following would load the "Recent Content" view block into the div upon click of the anchor.

<a data-lv-id="content_recent" data-lv-display="block_1" href="#">Click Me</a></p>
<div class="lazy-view">&nbsp;</div>

Example: On load

The following loads the view into itself upon page load.

<div id="lazy-view" data-lv-id="content_recent" data-lv-display="block_1" data-lv-execute="true" data-lv-target="lazy-view"></div>

Example: Fully Decorated

The following demonstrates all data attributes available. Note that the target attribute can accept either a class or an id.

<button data-lv-id="content_recent" data-lv-display="block_1" data-lv-args='1,5' data-lv-target='my-custom-area' data-lv-execute='true'>Click Me</button>

<div id="my-custom-area">Loading Content...</div>
Supporting organizations: 

Project information

Releases