1
我想單擊視圖中的鏈接時在節點上動態加載簡單內容。有沒有辦法做到這一點,而不涉及形式?drupal7 - 使用ajax加載節點(jQuery)
我想單擊視圖中的鏈接時在節點上動態加載簡單內容。有沒有辦法做到這一點,而不涉及形式?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