Created
March 3, 2015 11:59
-
-
Save keeprock/0239c578c68000d3a6ca to your computer and use it in GitHub Desktop.
Using History.API to display url in ajax loaded content
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function custom() { | |
drupal_add_js(drupal_get_path('module', 'CURRENT_MODULE') . '/CURRENT_MODULE_proto.js'); | |
$path = 'YOUR_PATH/' . $nid; | |
if ($alias = drupal_lookup_path('alias', $path)) { | |
$url = $alias; | |
} else { | |
$url = $path; | |
} | |
$commands[] = array( | |
'command' => 'CUSTOM_history', | |
'url' => '/' . $url | |
); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function($) { | |
Drupal.ajax.prototype.commands.CUSTOM_history = function(ajax, response, status) { | |
history.pushState(null, null, response.url); | |
} | |
}(jQuery)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment