Can I use this module to load node into defined div on front page? (dynamic ajax frontpage)
Or is there any other way?

Comments

nedjo’s picture

Status: Active » Fixed

This module doesn't do loading on its own. Rather, it is a helper module for other modules that do loading. It loads needed CSS and Javascript.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

jenlampton’s picture

Status: Closed (fixed) » Active

I'd also like to use this module to load a node (and all of it's associated CSS/JS). The example module shows how to submit a form using this method but not how to load a node.

My use case is that I am using the jquery menu module to build a menu in my left sidebar. I then have a custom module that loads each node in the content area when the corresponding menu item in the sidebar is clicked. Unfortunately the css and javascript is not added to the page, and the behaviors are not attached.

My javascript code looks like this:

    $('a.nid').click(function() {
      var id = $(this).attr('id');
      // TODO: update url before transfer!
      var url = Drupal.settings.basePath + '?q=custom-ajax/content/' + id;
      var loadurl = Drupal.settings.basePath + '?q=custom-ajax/loading/' + id;
        $('#ajax-load-node').load(loadurl, function() {
        $('#ajax-load-node').load(url);
        $('html, body').animate({scrollTop: $('#block-block-3').offset().top}, 'slow');
        //Drupal.attachBehaviors('#ajax-load-node');
      });
      //Drupal.attachBehaviors('#ajax-load-node');

      // The target should not be #ajax-load-node, or a node that will be
      // replaced, as this would mean no node is available for
      // ajax_load to attach behaviors to when all scripts are loaded.
      var target = $('#ajax-load-node').parentNode;
      Drupal.attachBehaviors(target);

      return false;
    });

As you can see, I've tried attaching the behaviors in three different places, but to no avail.

I'd like to rework this code to use jquery load, but I can't see how to from the example module provided.

Update: I've decided to go with the Ajax Links API module instead, since that one worked right away for me, but I'd still be curious about the answer to this one :)