【发布时间】:2014-05-08 10:55:49
【问题描述】:
我正在使用下面的代码在按钮单击后加载 jqgrid 数据。当我第一次单击按钮时,这是有效的。而我第二次单击该按钮意味着它没有加载。请帮我解决这个问题。
<script type="text/javascript">
$(document).ready
(
function () {
$('#btnContinue').live('click', function () {
var parent = $('#hf_val').val();
bindCustomers(parent);
});
}
);
var bindCustomers = function () {
alert('in');
// Set up the jquery grid
$("#jqTable").jqGrid
(
{
// Ajax related configurations
url: 'LoadCustomerData.ashx?TypeId='+ parent,
datatype: "json",
mtype: "POST",
// Specify the column names
colNames: ["CustomerId", "FirstName", "LastName"],
// Configure the columns
colModel: [
{ name: "CustomerId", index: "CustomerId", width: 40, align: "left" },
{ name: "FirstName", index: "FirstName", width: 100, align: "left" },
{ name: "LastName", index: "LastName", width: 200, align: "left"}],
// Grid total width and height
width: 550,
height: 200,
// Paging
toppager: true,
pager: $("#jqTablePager"),
rowNum: 5,
rowList: [5, 10, 20],
viewrecords: true, // Specify if "total number of records" is displayed
// Default sorting
//sortname: "Id",
//sortorder: "asc",
// Grid caption
caption: "A Basic jqGrid - Read Only"
}
).navGrid("#jqTablePager",
{ refresh: true, add: false, edit: false, del: false },
{}, // settings for edit
{}, // settings for add
{}, // settings for delete
{sopt: ["cn"]} // Search options. Some options can be set on column level
);
alert('loading finish');
}
</script>
【问题讨论】:
-
不要使用 .live,使用 .on
-
第二次加载时控制台是否出现错误?
-
不,我没有收到任何错误
-
@user3036342 这不是问题。事件每次都正确触发。
-
但是网格内容 url 没有被触发..
标签: jquery jqgrid jqgrid-asp.net jqgrid-php