drupal7 - 使用ajax加载节点(jQuery)
答
对于任何人在未来阅读本 - 从Drupal forums:
(function($) {
$(document).ready(function() {
var selector = '#main-menu li a'; // Or whatever selector you need
$(selector).click(function(e) {
e.preventDefault();
$.ajax({
url: $(this).attr('href') + '?ajaxrequest',
success: function(data) {
// I'm assuming here that the wrapper around your content region
// will be given an ID of 'region-content', you'll need to check that
$('#region-content').replaceWith(data);
}
});
});
});
})(jQuery);
和模块中:
<?php
function mymodule_page_alter(&$page) {
if (isset($_GET['ajaxrequest'])) {
echo render($page['content']);
drupal_exit();
}
}
?>
为我工作有一些调整。
没有窗体是的,但你必须为此创建模块 – drupality