Hello
I'm working to put ajax links in my list view to display the full content without page reload.
I have done like that (creation of a new module)
$items['my_module/ajax/%'] = array(
'page callback' => 'my_module_ajax_callback',
'page arguments' => array(2),
'access arguments' => TRUE,
'type' => MENU_CALLBACK,
);
return $items;
}
function my_module_ajax_callback($type = 'ajax', $nid) {
if ($type == 'ajax') {
$node = node_load($nid);
$output = drupal_render(node_view($node));
$output = '<div id ="dashboard_main_content">'.$output.'</div>';
$commands[] = ajax_command_replace('#dashboard_main_content',$output);
$page = array('#type' => 'ajax', '#commands' => $commands);
ajax_deliver($page);
}
else {
$output = t("This is some content delivered via a page load.");
return $output;
}
In the head of my view I put this :
// Add libraries
drupal_add_library('system', 'drupal.ajax');
drupal_add_library('system', 'jquery.form');
Then I print every link of my view like this :
<a href="/dev-drup/?q=fr/hicham_example/ajax/nojs/[nid]" class="use-ajax">[title]</a>
Every thing works fine, But the navigation history doesnt work.
Someone knows ho to add navigation history with drupal ajax ?