获取在jquery mobile

时间:2018-09-26 09:23:19

标签: javascript jquery jquery-mobile

我正在使用jQuery mobile 1.4.5

我将以下事件添加到文档中:

$(document).on("pagecreate", function (e) {

});

并在查看新页面时触发该事件,我的问题是如何获取正在创建的页面的ID? $.mobile.activePage未定义,页面容器窗口小部件的getActivePage()引发错误:

  

在初始化之前不能在pagecontainer上调用方法;尝试调用方法“ getActivePage”

感谢您的帮助。

编辑:

我用过:

$.mobile.pageContainer.pagecontainer("getActivePage")[0].id

它不会抛出错误,但是会返回当前页面的ID,而不是要创建的页面,有什么建议吗?

1 个答案:

答案 0 :(得分:1)

选中buildscript { repositories { maven { url "http://dl.bintray.com/populov/maven" } mavenCentral() jcenter() google() maven { url 'https://maven.google.com/' name 'Google' } maven { url "https://jitpack.io" } } dependencies { classpath 'com.android.tools.build:gradle:3.2.0' classpath "io.realm:realm-gradle-plugin:5.1.0" classpath 'me.tatarka:gradle-retrolambda:3.7.0' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { maven { url 'https://maven.google.com/' name 'Google' } maven { url "http://dl.bintray.com/populov/maven" } mavenCentral() jcenter() maven { url "https://jitpack.io" } } subprojects { project.configurations.all { resolutionStrategy.eachDependency { details -> if (details.requested.group == 'com.android.support' && !details.requested.name.contains('multidex') ) { details.useVersion "27.1.1" } } } } } task clean(type: Delete) { delete rootProject.buildDir } // Define versions in a single place ext { // Sdk and tools minSdkVersion = 19 targetSdkVersion = 27 compileSdkVersion = 27 buildToolsVersion = '27.0.3' // App dependencies supportLibraryVersion = '28.0.0' butterKnifeVersion = '8.8.1' retrofitVersion = '2.3.0' okhttpVersion = '3.8.0' junitVersion = '4.12' glideVersion = '4.7.1' googleServiceVersion = '15.0.1' permissionDispatcherVersion = '3.1.0' rxjavaVersion = '2.1.12' rxandroidVersion = '2.0.2' lifecycleVersion = '1.1.1' daggerVersion = '2.16' pagingLibraryVersion = '1.0.1' autoScrollViewPagerVersion = '1.1.2' nvWebSocketClientVersion = '2.5' lombokVersion = '1.16.20' constraintLayoutVersion = '1.1.3' } ,这是演示

event.target