我是moodle中的新成員,並且始終在客戶端進行編程。我想也許我因爲這個原因錯過了一些東西。根據他在組合中選擇的內容,我需要爲用戶提供各種UI元素。所以我正在考慮根據戰略(設計模式)寫出這些文章。從mod_form.php一個對象,我嘗試執行這樣的事情:根據select元素的onchange事件添加新的moodle UI元素
正在執行和日誌打印在控制檯中,但絕不會在執行中displayStrategy.php內容$this -> _form -> addElement('select', 'displayStrategy', get_string('displayStrategy', 'xForum'), $displayStrategy, array('onchange' => 'javascript: function loadStrategy(selVal){
$.ajax({
type: "POST",
url: "../mod/xForum/action/displayStrategy.php",
data: { class: selVal }
}).done(function(msg) {
console.log("Strategy was executed");
});
}; loadStrategy(this.value);'));
,一「加載」效果被添加到當前視圖,最後一個問題是我還需要在寫入UI的同一個對象中調用一個函數(mod_form.php中執行所有$ this - > _form - > addElement的函數(...))
你能幫我一把嗎?我如何根據戰略執行這些方法?
非常感謝!