我有一个构建应用程序用户界面的 javascript 函数。
首先,我将所有需要的元素附加到一个 div 中,其中一个是 jqgrid。
这是一个例子:
//Generate the controls
var c = '';
c += '<table>';
c += '<tr>';
c += '<td><label for="from_date">Start Date</label><td>';
c += '<td><input type="text" id="from_date"/></td>';
c += '<td><label for="to_date">End Date</label><td>';
c += '<td><input type="text" id="to_date"/></td>';
c += '</tr>';
c += '</table>';
//Perform an ajax call update date pickers
$.ajax({
url: "php/daily_schedule/daily.schedule.get.date.limits.php",
dataType: "json",
success: function(data) {
//Update the values of the inputs
$("#from_date").val(data.MAX);
$("#to_date").val(data.MAX);
//Split json results to pass new date objects
var max_array = data.MAX.split('-');
var max_yy = max_array[0];
var max_mm = max_array[1]-1;
var max_dd = max_array[2];
var min_array = data.MIN.split('-');
var min_yy = min_array[0];
var min_mm = min_array[1]-1;
var min_dd = min_array[2];
//Initiate the from date picker
$( "#from_date" ).datepicker({
dateFormat :"yy-mm-dd",
defaultDate: new Date(max_yy, max_mm, max_dd),
maxDate: new Date(max_yy, max_mm, max_dd),
minDate: new Date(min_yy, min_mm, min_dd),
changeMonth: false,
numberOfMonths: 1,
onClose: function( selectedDate ) {
$( "#to_date" ).datepicker( "option", "minDate", selectedDate );
},
onSelect:function(){
load_FLT();
}
});
//Initiate the to date picker
$( "#to_date" ).datepicker({
dateFormat :"yy-mm-dd",
defaultDate: new Date(max_yy, max_mm, max_dd),
maxDate: new Date(max_yy, max_mm, max_dd),
minDate: new Date(min_yy, min_mm, min_dd),
changeMonth: false,
numberOfMonths: 1,
onClose: function( selectedDate ) {
$( "#from_date" ).datepicker( "option", "maxDate", selectedDate );
},
onSelect:function(){
load_FLT();
}
});
}
});
//Append the controls
$('#daily_schedule_core_filters_container').append(c)
//Generate grid elements
$('#daily_schedule_core_grid_container').append('<table id="daily_schedule_grid"></table>')
$('#daily_schedule_core_grid_container').append('<table id="daily_schedule_grid_pager"></table>')
然后我添加网格:
//Create the daily schedule grid
jQuery("#daily_schedule_grid").jqGrid({
url:'php/daily_schedule/daily.schedule.grid.php',
datatype: "json",
hidegrid: false,
等等等等
我的问题是我将它添加到我的网格中:
postData: {
df: function() { return $('#from_date').val()},
dt: function() { return $('#to_date').val()}
},
mtype: 'POST',
并且它不断发送 POST 作为未定义的值。
关于我做错了什么的任何想法?