我使用jquery无限滚动插件进行分页,并且在将页面直接运行到浏览器时效果很好。但是如果我通过jquery load方法调用页面它就不起作用了。我可以得到第一组结果,然后我甚至看不到加载器。请帮忙。感谢
使用yii无限滚动扩展的代码
$this->widget('ext.yiinfinite-scroll.YiinfiniteScroller', array(
'contentSelector' => '#container',
'itemSelector' => 'ul.wlist',
'loadingText' => 'Loading next 15 rows...',
'donetext' => 'Loading Completed.',
'pages' => $pages,
));
单击按钮时打开bootstrap模型弹出
<button name="add_more" class="btn btn-primary" id="add_more" type="submit" onClick="show_dest();">Add More?</button>
<a data-toggle="modal" data-target="#myModal" style="cursor:pointer;"><span id="click_frm" style="display:none">spn</span></a>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog" style="width:70%; margin-left:auto; margin-right:auto;">
<div class="modal-content">
<div class="modal-body" style="display:inline-block; width:100%;" >
<button type="button" class="close" data-dismiss="modal" aria-hidden="true" style="position:absolute; top:10px; right:10px;" >×</button>
<div id="res_search" style=" height:500px; overflow:auto; margin-top:-20px;"></div>
</div>
</div>
</div>
</div>
<script type="text/javascript">
function show_dest()
{
var r_id=document.getElementById('reg_id').value;
$('#click_frm').trigger('click');
}
$(document).ready(function(){
var reg_id=document.getElementById('reg_id').value;
$("#res_search").load("/site/selectmore", {'reg_id':reg_id}, function(){
});
});
</script>
答案 0 :(得分:1)
男孩,你有一些丑陋的代码
首先,用更清洁的版本替换脚本
<script type="text/javascript">
function show_dest() {
// WHAT IS THE PURPOUSE OF SETTING RID HERE ?!
// BECAUSE IT READS REG_ID AND THEN DOES NOTHING WITH THE GOTTEN VALUE?
var rId = $('#reg_id').val();
$('#click_frm').trigger('click');
}
$(function() {
var rId = $('#reg_id').val();
$("#res_search").load(
"/site/selectmore",
{ 'reg_id': rId },
function(data) {
// YOU DO NOTHING ON SUCCESS IS THIS OK?
}
);
);
</script>
正确格式化代码可以帮助您解决此类错误
现在阅读我在代码
使用Chrome开发者工具Javascript控制台(F12 in。) Chrome)调试javascript中的错误