If a node is loaded through ajax it appears the ShareThis js is not initialised.

CommentFileSizeAuthor
#2 ajax_loaded_fix-2956948-1.patch3.25 KBtanc

Comments

tanc created an issue. See original summary.

tanc’s picture

Status: Active » Needs review
StatusFileSize
new3.25 KB

Patch adds an optional javascript library which can be included on a render array which is loaded via ajax. This should then trigger the re-initialisation of the ShareThis javascript and in turn make the buttons appear.

tanc’s picture

An example use:

Given a grid view of nodes which loads an individual node via ajax in a modal, the following could be used to attach the javascript:

/**
 * Implements hook_preprocess_views_view().
 */
function mymodule_preprocess_views_view(&$variables) {
  // Make sure this operates on the images_overview view only.
  if (!isset($variables['view_array']['#name']) || $variables['view_array']['#name'] == 'images_overview') {
    $variables['view_array']['#attached']['library'][] = 'sharethis_block/sharethis.ajax';
  }
}

  • tanc committed 30ba33f on 8.x-1.x
    Issue #2956948 by tanc: ShareThis javascript does not initialise on ajax...
tanc’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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