我没有太多接触过jQuery插件。我正在尝试创建一个dataTable网格。但是,数据不会加载到表中。所有细胞都得到“未定义”的值。坚持建议。谢谢。以下是示例配置:
function createModelTable(){
var htmlTable = '';
for(var i = 1; i <= line; i++){
var htmlTr = '';
if(i % 2 == 0){
htmlTr = '<tr class="bgcolor">';
}else{
htmlTr = '<tr>';
}
for(var j = 0; j <= 2; j++){
var index = line * j + i;
index = pad(index, 3);
if( lotIds.indexOf(gameType) > -1 && index > 97 ){
index = '';
}
if ((gameType == 3 && index > 23) || (gameType == 10 && index > 82)
|| (gameType == 11 && index > 80) || (gameType == 16 && index > 79)) {
htmlTr += '<td></td>';
} else {
htmlTr += '<td><span class="text1">' + index + '</span><span class="open_num" id="draw_td_' + index + '"></span></td>';
}
}
htmlTr += '</tr>';
htmlTable += htmlTr;
}
$('#cqssc_draw_list_tbody').html(htmlTable);
}
HTML:
<div class="sl-draw-list">
<div class="sl-draw-list-t">
<span class="sl-draw-list-t-red"><span id="search_result_day"><?php echo $date;?></span> 开奖号码</span>
<ul id="sl_draw_list_t_tab" class="sl-draw-list-t-tab">
<li class="active" date="<?php echo $date;?>"><a href="javascript:;">今天</a></li>
<li date="<?php echo $yes;?>"><a href="javascript:;">昨天</a></li>
<li date="<?php echo $bef;?>"><a href="javascript:;">前天</a></li>
</ul>
<div class="sl-draw-list-t-date">
按日期查询:<input type="text" value="<?php echo $date; ?>" id="cqssc_draw_time_box" class="cqssc-draw-time-box">
<input type="hidden" id="lottery-id" value="<?php echo $output['id'];?>" />
</div>
</div>
<div class="sl-draw-list-table-out">
<table width="100%" cellpadding="0" cellspacing="0" class="winning-lottery-table ssq-lottery-table">
<thead>
<tr>
<th width="33.3%"><span class="text1">期号</span><span class="text2">开奖号</span></th>
<th width="33.3%"><span class="text1">期号</span><span class="text2">开奖号</span></th>
<th><span class="text1">期号</span><span class="text2">开奖号</span> </th>
</tr>
</thead>
<tbody id="cqssc_draw_list_tbody"></tbody>
</table>
</div>
</div>