Skip to content

Load Views via Ajax using data selectors provided by Archipelago #427

@DiegoPino

Description

@DiegoPino

What?

Many times one (you/me/them) need to load dynamically based on interaction or just async on load a list of things (a View). Might be because the list depends on conditions set on a Metadata Display with arguments, or on interaction (clicks). Writing code to do that is a bit advanced and might require rewiring some stuff. But all our users have access to editing their twig templates, so following the Bootstrap idea, let's use data- selector to give Ajax/JS commands on what can be done.

The idea is simple:

You output this:

<button id="aRequiredID" 
data-sbf-view-id="creative_work_series_children" 
data-sbf-view-display-id="block_1" 
data-sbf-view-arguments="45" 
data-sbf-view-render-target="the_target" 
data-sbf-view-event="click">
Click me to load creative_work_series_children View 
with block_1 display 
passing argument 45 
inside another DIV with a class named "js-view-dom-id-the_target"
</button>

<div class="js-view-dom-id-the_target">HERE WILL BE MY VIEW LOADED</div>

Metadata

Metadata

Assignees

Labels

Drupal ViewsAsk and you should receiveJavascriptFavourite language of a PHP developerUI driven hintsShow stuff on screen so people have less guessing to doUXLike UI but with an XenhancementNew feature or request

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions