我目前有一个从上到下显示的页面:一个响应表,其中包含我公司提供的类列表,一个显示每个类的位置的地图,以及该类的议程。我的雇主希望我在另一个页面中添加一个锚链接,直接链接到页面的议程部分。
问题是,当单击锚点时,用户被重定向到议程(期望的结果),但随后对服务器的ajax调用结束,上面的表格扩展并推迟议程。
我试图将表格包装在一个基于表格内容的计算高度的div中,但最小高度似乎是在事实之后应用的。
以下是锚定链接的网址:http://www.grastontechnique.com/clinicians/M1_Trainings#m1-training-agenda
我还将包含与表和ajax调用相关的代码片段。
这是对服务器的调用
$scope.loadData = function () {
$.ajax({
url: '@Url.Action("getTrainings", "Clinicians")',
data: { "trainingType": "M1" },
success: function (data) {
newData = JSON.parse(data)
index = 0;
tableHeight = 77;
trainingsTable = document.getElementById("m1-trainings-table-container");
newData["records"].forEach(function (object) {
if (newData["records"][index]["Early_Bird_Discount_Amount__c"] > 0)
{
tableHeight += 141;
}
else
{
tableHeight += 125;
}
newData["records"][index].firstDayStartTime = BuildTimeString(new Date((newData["records"][index]["First_Day_Start__c"].slice(0, -9) + "Z").replace('+', '.')));
newData["records"][index].firstDayEndTime = BuildTimeString(new Date((newData["records"][index]["First_Day_End__c"].slice(0, -9) + "Z").replace('+', '.')));
newData["records"][index].lastDayStartTime = BuildTimeString(new Date((newData["records"][index]["Final_Day_Start__c"].slice(0, -9) + "Z").replace('+', '.')));
newData["records"][index].lastDayEndTime = BuildTimeString(new Date((newData["records"][index]["Final_Day_End__c"].slice(0, -9) + "Z").replace('+', '.')));
newData["records"][index]["First_Day_Start__c"] = new Date((newData["records"][index]["First_Day_Start__c"].slice(0, -9) + "Z").replace('+', '.')).toDateString();
newData["records"][index]["Final_Day_Start__c"] = new Date((newData["records"][index]["Final_Day_Start__c"].slice(0, -9) + "Z").replace('+', '.')).toDateString();
index += 1;
});
trainingsTable.style.minHeight = tableHeight + "px";
$scope.trainingsList = newData['records'];
$scope.$apply();
}
});
};
这是表容器
<div class="container spaced-container" ng-app="trainingsApp">
<div class="row" ng-controller="trainingsController">
<div class="col-md-8 col-md-offset-2">
<h3 class="training-section-header text-center">M1-Basic Training Schedule</h3>
<p class="text-center">To qualify for the Early Bird Special (Save $50) your registration must be paid for anytime 30-days prior to your training date.<br />
<input type="text" id="zip-input" class="locate-a-provider-input" style="margin: 25px auto; padding-left: 5px;" ng-model="searchQuery" placeholder="Search Trainings"></p>
<div id="m1-trainings-table-container">
<table class="table table-responsive calculator">
<thead>
<tr>
<th style="width: 10%" class="vertical-centered-parent"><p>State</p></th>
<th style="width: 35%" class="vertical-centered-parent"><p>Location</p></th>
<th style="width: 35%" class="vertical-centered-parent"><p>Time & Date</p></th>
<th style="width: 20%" class="vertical-centered-parent"><p>Register</p></th>
</tr>
</thead>
<tbody>
<tr class="table-row vertical-centered-parent" ng-repeat="training in trainingsList | filter:searchQuery as results">
<td class="state-td vertical-centered-parent" id="responsive-state-parent">
<span class="responsive-table-spans">State: </span>
<p class="responsive-paragraph">{{training.Venue_State__c}}</p>
</td>
<td class="location-td vertical-centered-parent">
<p class="min-width">
<span class="responsive-table-spans">Venue:<br /></span>
{{training.Venue_Name__c}}<br />
{{training.Venue_Street_Address_1__c}}<br />
{{training.Venue_City__c}}, {{training.Venue_State__c}} {{training.Venue_Postal_Code__c}}
</p>
</td>
<td class="time-date-td vertical-centered-parent">
<p class="min-width">
<span class="responsive-table-spans">Dates:<br /></span>
<span style="color: #F57149" ng-if="training.Capacity_Full__c > 80 && training.Capacity_Full__c < 99.99">Closing Soon<br /></span>
<span style="color: #F57149" ng-if="training.Capacity_Full__c >= 100">Wait List<br /></span>
<span style="color: #F57149" ng-if="training.Early_Bird_Discount_Amount__c > 0 && training.Capacity_Full__c < 100">Early Bird Special: Save ${{training.Early_Bird_Discount_Amount__c}}!<br /></span>
{{training.First_Day_Start__c}}<br />
{{training.firstDayStartTime}} - {{training.firstDayEndTime}}<br />
{{training.Final_Day_Start__c}} <br />
{{training.lastDayStartTime}} - {{training.lastDayEndTime}}<br />
</p>
</td>
<td class="sign-up-td button">
<button class="rounded-button button-sign-up" ng-click="toTraining(training.Id)">Sign Up</button>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
非常感谢任何帮助。
Danny D。