0
我做了一個模塊,創建一個塊,並使用#attached我添加了我的自定義.js文件來阻止內容,沒有Drupal.behaviors和函數($)我的代碼工作的東西就像一個時鐘在另一頁(Drupal的以外),但在Drupal,我不知道如何添加一個功能。js文件 這裏是我的代碼:使用函數在drupal中的自定義JavaScript文件
(function($){
Drupal.behaviors.mymodule = {
attach:function(context, settings) {
function show_more(count){
var counter = count;
var id = document.getElementById("id").value;
var xmlhttp;
if (window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest;
}
xmlhttp.onreadystatechange = function() {
if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
document.getElementById("div_id").innerHTML =xmlhttp.responseText;
}
}
xmlhttp.open("POST","some_page.php",true);
xmlhttp.setRequestHeader("Content-type","application/x-www-form- urlencoded");
xmlhttp.send("counter="+encodeURIComponent(counter)+"&id="+encodeURIComponent(id ));
$("#div_id").fadeToggle(2000);
}
}
}
})(JQuery);
我是新來的Drupal和jQuery請幫我 並請告訴我如何在我的內容中呼叫show_more功能 預先感謝您
謝謝我的問題解決了 – fardad 2015-04-05 12:47:24