0

I am attempting to add history states to view items that are loaded using the infitine scroll module. On my first attempt, I am adding the following code to the infinite scroll.js file in the load section. I have partial success in using Drupal.settings.basePath variable, however, I would like to get the node that gets loaded as opposed to the baseurl. Is there a call in javascript for this? Here is my sample so far:

var baseUrl = Drupal.settings.basePath;
history.pushState('', '', baseUrl);
0

You can add the node ID manually to Drupal settings with drupal_add_js(), for example from a preprocess function.

// PHP
$setting = array('setting_1' => 'value_1', 'setting_2' => 'value_2');
drupal_add_js($setting, 'setting');
// JavaScript
var nodeId = Drupal.settings.setting_1;
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.