gpt4 book ai didi

css - Knockout.js 和大数据集也使下拉列表变慢

转载 作者:行者123 更新时间:2023-12-05 00:11:18 25 4
gpt4 key购买 nike

有谁知道为什么这个页面的性能在涉及到-ALL-选项的下拉列表时很慢?我一定是在 knockout.js 上做错了什么才会发生这种情况。对于较小的游戏列表,它可以快速打开。

Tournament Schedule

Javascript

(function (app, $, undefined) {

app.viewModel = app.viewModel || {};

function Schedule() {

var self = this;

self.loaded = ko.observable(false);
self.divisionId = ko.observable();
self.games = ko.observableArray(null);

self.search = function(url) {
app.call({
type: 'POST',
data: { divisionId: self.divisionId() },
url: url,
success: function (result) {
self.games([]);
self.games.push.apply(self.games, result);
self.loaded(true);
}
});
};

self.init = function (options) {
app.applyBindings();
};

};

app.viewModel.schedule = new Schedule();

} (window.app = window.app || {}, jQuery));

模板

     <div class="games hidden" data-bind="if: schedule.games(), css: { 'hidden': !schedule.games() }">
<div data-bind="if: schedule.games().length > 0">
<div data-bind="foreach: schedule.games">

<h2><span data-bind="html: Name"></span></h2>
<hr />
<div class="games row" data-bind="foreach: Games">
<div class="span4">
<div class="game game-box new-game-box">
<div class="datetime-header clearfix new-game-box">
<span class="time"><span data-bind="html: DateFormatted"></span> - <span data-bind="html: TimeFormatted"></span></span>,
<span class="gym" data-bind="text: Venue"></span>
</div>
<div class="team-game clearfix new-game-box" data-bind="css: { winner: AwayTeamIsWinner }">
<span class="team">
<a target="_blank" href="#" data-bind="html: AwayTeamName, attr: { href: AwayTeamLink }"></a>
</span> <span class="score" data-bind="html: AwayTeamScoreDisplay"></span>
</div>
<div class="team-game clearfix new-game-box" data-bind="css: { winner: HomeTeamIsWinner }">
<span class="team">
<a href="#" target="_blank" data-bind="html: HomeTeamName, attr: { href: HomeTeamLink }"></a>
</span> <span class="score" data-bind="html: HomeTeamScoreDisplay"></span>
</div>
<div class="buttons clearfix">

<span class="division" data-bind="html: 'Division ' + DivisionName"></span>,
<span data-bind="text: GameTypeName"></span>
<div class="btn-group">
<a rel="nofollow, noindex" title="Add to calendar" href="#" class="btn btn-mini" data-bind="attr: { href: CalendarLink }"><i class="icon-calendar"></i></a>
<a target="_blank" title="Gym Details" href="#" class="btn btn-mini" data-bind="attr: { href: GymLink }"><i class="icon-map-marker"></i></a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="hidden" data-bind="if: (schedule.games() && schedule.games().length == 0), css: { 'hidden': !schedule.games() }">
No games found for this event.
Scores will be available here the day before the event however the schedule might already be posted under <a href="@Url.Action(MVC.Event.Documents(Model.Event.Id, Model.Event.Slug))">documents</a>.

</div>
<script type="text/javascript">
app.viewModel.schedule.init({});
</script>

最佳答案

我下载了您的 HTML 和 CSS 并做了一些测试。我能够通过删除以下 CSS 来解决问题:

.ui-widget :active {
outline: none
}

current page 上进行测试, 在控制台执行document.styleSheets[0].deleteRule(23)

更多测试表明,下拉菜单仅在 Chrome (30) 中较慢。 Firefox (23) 和 IE (10) 没有问题。

关于css - Knockout.js 和大数据集也使下拉列表变慢,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19883679/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com