willy800510 / logoWeb

Logo Web
0 stars 0 forks source link

幫助中心 helpCenter.php 換左導覽 #9

Closed willy800510 closed 3 years ago

willy800510 commented 3 years ago

helpCenter的左導覽是用include引入leftbar_help.php到helpCenter.php

helpCenter.php第48行

<div id="leftRow" class="col-2 px-0">
<?php include("template/leftbar_help.php"); ?>
</div>

預想要點選leftbar_help.php的chevron可以換成left bar.php,但此方法沒有動靜... chevron from (left bar_help.php)第3行

<button class="material-icons" onclick="change_leftbar()">chevron_left</button>

helpCenter.php第566行

function change_leftbar() {
$('#leftRow').load('template/leftbar.php');
}

也嘗試用$ajax,但也沒有動靜

chevron from (left bar_help.php)第4行

<button class="material-icons" onclick="change_leftbar('template/leftbar.php')">chevron_left</button>

helpCenter.php第569行

function change_leftbar(_url){
$.ajax({
url : _url,
type : 'post',
success: function(data) {
$('#leftRow').html(data);
},
error: function() {
$('#leftRow').text('An error occurred');
}
});
};
joyuhuang commented 3 years ago

load 或 ajax 都有效,問題是出在

<button class="material-icons" onclick="change_leftbar()">chevron_left</button>

的onclick會找不到function,因為這個function寫在不同檔案

查到可以將 function change_leftbar(_url){ ...... } 的寫法改成 change_leftbar = function () { ...... } ,這樣就可以被讀取到