[英]$(document).Ready() loads Flexigrid, but not when called again by other function outside $(document).Ready()
I have a function called "loadTimeTrackersGrid()", which loads a flexigrid. 我有一个名为“loadTimeTrackersGrid()”的函数,它加载了一个flexigrid。 The setup looks like this :
设置如下所示:
$(document).ready(function () {
var editTrackerID = 0;
loadTimeTrackersGrid();
)};
The beginning of the function looks like this : 函数的开头如下所示:
function loadTimeTrackersGrid(caseStatus) {
var url = 'Utilities/DataViewHandlers/ViewTimeTrackers.ashx?CaseFileID=' + $('#hidCaseFile').val();
if ($('#hidTaskID').val() !== "")
url += '&TaskID=' + $('#hidTaskID').val();
if (caseStatus == "NI") {
url += '&NonInvoiced=1';
}
$('#viewTimeTrackersGrid').flexigrid({
url: url,
dataType: 'json',
method: 'get',
As you can see it calls another page which contains a stored procedure which returns a set of rows and a jsonwriter then puts the returned columns into the flexigrid. 如您所见,它调用另一个页面,其中包含一个返回一组行的存储过程,然后一个jsonwriter将返回的列放入flexigrid中。
But the problem I am having is outside the (document).ready(), when I have a function that calls the "loadTimeTrackersGrid()", it never reloads the flexigrid or makes a call to the file that contains the stored procedure. 但我遇到的问题是在(document).ready()之外,当我有一个调用“loadTimeTrackersGrid()”的函数时,它从不重新加载flexigrid或调用包含存储过程的文件。
My function(that I am trying to get to work) looks like this : 我的功能(我试图开始工作)看起来像这样:
function returnInvoicedItems() {
loadTimeTrackersGrid();
$('.menuBtn img').parent().children('ul').removeClass('menuShow');
}
And this is how I am calling "returnInvoicedItems" function: 这就是我调用“returnInvoicedItems”函数的方式:
<li><a href="#" onclick="returnInvoicedItems()">Non Invoiced Tracker</a></li>
I am not sure, but I think I can see the problem. 我不确定,但我想我能看到问题所在。 Your second function returnInvoicedItems() that calls loadTimeTrackersGrid() , it does have a jQuery code (in the line
$('.menuBtn img').parent().children('ul').removeClass('menuShow');
. Now, if you have a jQuery call, don't you have to do make that call inside $(document).ready() ? 你的第二个函数returnInvoicedItems()调用loadTimeTrackersGrid() ,它确实有一个jQuery代码(行
$('.menuBtn img').parent().children('ul').removeClass('menuShow');
现在,如果你有一个jQuery调用,你不必在$(document).ready()中调用吗?
Try to move returnInvoicedItems() inside $(document).ready() and see what happens. 尝试在$(document).ready()中移动returnInvoicedItems( ) ,看看会发生什么。
这就像一个宝石:
$('#viewTimeTrackersGrid').flexOptions({ url: 'Utilities/DataViewHandlers/ViewTimeTrackers.ashx?' + invoicedUrl + '&NonInvoiced=1' }).flexReload();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.