i am using jtable when i search records a i am getting this error JavaScript runtime error: cannot call methods on jtable prior to initialization; attempted to call method 'load' i am getting this error only in IE 9
var Visits = new Array();
var Procedures = new Array();
var Statuses = new Array();
var CoreLabStatuses = new Array();
$("#LstSelectedVisit option").each(function (index, ele) {
Visits.push($(this).val());
});
$("#LstSelectedProcedure option").each(function (index, ele) {
Procedures.push($(this).val());
});
$("#LstSelectedStatus option").each(function (index, ele) {
Statuses.push($(this).val());
});
$("#LstSelectedCoreLabStatus option").each(function (index, ele) {
CoreLabStatuses.push($(this).val());
});
/* ### Getting selected Visits, Procedures and Status(End) ### */
//calling server side to blank temp data function
$.ajax({
url: '@Url.Action("BlankTempData")',
type: 'POST',
//contentType: 'application/json',
//data: model.serialize(),
success: function (result) {
$('#CaseGridContainer').jtable('load', {
Trial: $('#ddlTrial').val(),
Received_Date: $('#txtReceivedDate').val(),
Site_Id: $('#ddlSite').val(),
Study_Date: $('#txtStudyDate').val(),
ReceivedDateStart: $('#txtReceivedDateStart').val(),
ReceivedDateEnd: $('#txtReceivedDateEnd').val(),
StudyDateStart: $('#txtStudyDateStart').val(),
StudyDateEnd: $('#txtStudyDateEnd').val(),
Subject_id: $('#txtSubjectID').val(),
Job_id: $('#txtJobID').val(),
MDDX_id: $('#txtMDDXID').val(),
Patient_Name_tag: $('#txtPatientsNameTAG').val(),
CoreLab: $('#ddlCoreLab').val(),
lstVisit: Visits.join(),
lstProcedure: Procedures.join(),
lstStatus: Statuses.join(),
lstCoreLabStatus: CoreLabStatuses.join()
});
}
});
Basically this problem occurs because jtable is not initialized. First, make sure you are using latest jtable api (v2.4.0) if you aren't already. Technically you could fix this just by first initializing with something like following
However, you need to first find out why jtable ran into that situation.
Assuming that you are having this problem with latest version of jtable API I'd fix this by not loading and setting jtable in same go. i.e. first set jtable definition and then load jtable in a different statement as follows.
Make sure that both above commands are in same function block. So in your case it should be like follows.
Then if issue is still occurring in IE9 browser then put some sleep for IE9 case between jtable set and load method.