V
V
Vladimir2016-01-29 16:36:33
Drupal
Vladimir, 2016-01-29 16:36:33

How to load a block on click on a link via ajax?

Please tell me, you need to load a certain block via ajax by clicking on the link, is there any ready-made module? Or maybe some article on how to do it?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrey Dyrkov, 2016-01-29
@VIKINGVyksa

You can find it in Google, why ask here? Here they ask about the code ...
Here is the bike

;(function(w,d,b){
 d.getElementsByTagName('a').

for(/*типо цикл*/){
  d[i].addEventListener('click',function(e){
  var self = this,
       blockName = self.getAttibute('data-block');
    e.preventDefault();

    /*ну и ajax*/
 
 },false);
}
})(window,document,document.body);

The problem with this method is that there are a lot of event handlers in the document, the more links, the more event handlers. Delegate to your taste)

D
Drupby, 2016-01-29
@drupby

As an option, use ctools modal (an example of using drup.by/articles/vsplyvayushchee-modalnoe-okno-sz... - just replace the window display by time per click)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question