[英]drupal7 - loading node using ajax(jquery)
我想在單擊視圖中的鏈接時在節點上動態加載簡單內容。 有沒有一種方法不涉及表格?
對於以后閱讀此書的任何人-在Drupal論壇中 :
(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();
}
}
?>
通過一些調整為我工作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.