gpt4 book ai didi

jQuery 手机 : Can I "uninitialize" the page?

转载 作者:行者123 更新时间:2023-11-28 20:09:05 25 4
gpt4 key购买 nike

有没有办法“取消初始化”已由 jQuery Mobile 初始化的页面?我在单个页面上运行整个测试套件,并希望在每次测试后清理 JQM。目前设置如下:

before(function () {
$.mobile.ajaxEnabled = false;
$.mobile.linkBindingEnabled = false;
$.mobile.hashListeningEnabled = false;
$.mobile.pushStateEnabled = false;
$.mobile.changePage.defaults.changeHash = false;
$.mobile.autoInitializePage = false;
$.mobile.defaultPageTransition = 'slide';

this.$el = $('<div></div>');
$(document.body).append(this.$el);
});

after(function () {
this.$el.remove();
});

afterEach(function () {
this.$el.empty();
});

it('some test', function () {
var page = $('<div data-role="page">...</div>')
this.$el.append(page);

// Each test will perform calls like these at some point
$.mobile.initializePage();
$.mobile.changePage(page, {
allowSamePageTransition: true,
pageContainer: this.$el,
transition: 'none'
});

assert_whatever();
});

第一个测试运行正常,但是当第二个测试运行时出现错误:

cannot call methods on loader prior to initialization; attempted to call method 'show'

最佳答案

似乎设置:

$.mobile.activePage = undefined;
$.mobile.loaderWidget = undefined;

在每次测试之前。

关于jQuery 手机 : Can I "uninitialize" the page?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15395857/

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