我有一个数据表进入弹出窗口。当我尝试使用ajax请求更改数据表中的显示值时,数据表值不会更改。我可以看到检索到的数据是正确的,但这些数据没有显示数据表。
以下是代码:
<script>
function CreateChart() {
var chart = AmCharts.makeChart("piechartdiv", {
"type": "pie",
"theme": "light",
"fontFamily":"Calibri",
"dataProvider": [{
"product":"Following",
"value": @following,
"color": "#009688"
}, {
"product":"Not following",
"value": @notFollowing,
"color": "#555555"
}],
"legend": {
"align" : "right",
"fontSize" : 14
},
"marginLeft":-100,
"marginTop":-45,
"marginBottom":0,
"labelsEnabled":false,
"colorField": "color",
"valueField": "value",
"titleField": "product",
"outlineAlpha": 0.4,
"depth3D": 15,
"balloonText": "[[title]]<br><span style='font-size:14px'><b>[[value]]</b> ([[percents]]%)</span>",
"angle": 20,
"export": {
"enabled": true
}
});
jQuery('.chart-input').off().on('input change', function () {
var property = jQuery(this).data('property');
var target = chart;
var value = Number(this.value);
chart.startDuration = 0;
if (property == 'innerRadius') {
value += "%";
}
target[property] = value;
chart.validateNow();
});
chart.addListener("clickSlice", function (event) {
if ( event.dataItem.title == 'Unfollowing')
{
document.getElementById("s_open").click();
}
});
}
var isAjax = @isAjax;
if(isAjax)
{
CreateChart();
}
else
{
AmCharts.ready(function () {
CreateChart();
});
}
<button id="s_open" class="s_open btn-default" style="display:none;">Open popup</button>
<div id="testfollowing" style="display:none;">
<div class="row" style="border-radius:5px; padding:20px; background-color:#fff;">
<table id="following" class="table table-striped" cellspacing="0">
<thead>
<tr>
<th>Following</th>
</tr>
</thead>
<tbody>
@Html.Raw(comparedDataTable.ToString())
</tbody>
</table>
<button class="btn s_close btn-danger">Close</button>
</div>
这是弹出的表格代码部分:
var isAjax = @isAjax;
if(isAjax)
{
dataTables.taskList = $('#following').dataTable({
// the same initialization params used but left out here for brevity
dom: 'Bfrtip',
buttons: [
'excelHtml5',
'csvHtml5'
],
"bServerSide": true,
"bRetrieve": true,
});
$(document).ready(function () {
// Initialize the plugin
$('#').popup({
color: 'black',
opacity: 0.5,
transition: '0.3s',
scrolllock: true
});
});
}
else
{
$(new function () {
$('#following').DataTable( {
dom: 'Bfrtip',
buttons: [
'excelHtml5',
'csvHtml5'
],
} );
});
$(document).ready(function () {
// Initialize the plugin
$('#testfollowing').popup({
color: 'black',
opacity: 0.5,
transition: '0.3s',
scrolllock: true
});
});
}
数据是通过Razor而不是Ajax提供的,只是使用Ajax的请求。我怎样才能解决这个再生问题?