我正在尝试在弹出框中编写一个滑块。
我正在使用Jquery。 弹出窗口正常工作,它按照我想要的方式弹出。
对于滑块我使用Swiper jquery库。
如果我自己测试popup div中的代码,滑块效果很好,但必须有一些碰撞。
这是我刚才描述的链接。
http://seveloff.com/test/popup.html
这是弹出式代码:
java.lang.StackOverflowError
at java.io.FilterInputStream.read(FilterInputStream.java:118)
at com.android.org.bouncycastle.asn1.DefiniteLengthInputStream.read(DefiniteLengthInputStream.java:74)
at java.io.FilterInputStream.read(FilterInputStream.java:118)
at com.android.org.bouncycastle.asn1.DefiniteLengthInputStream.read(DefiniteLengthInputStream.java:74)
at java.io.FilterInputStream.read(FilterInputStream.java:118)
at com.android.org.bouncycastle.asn1.DefiniteLengthInputStream.read(DefiniteLengthInputStream.java:74)
at java.io.FilterInputStream.read(FilterInputStream.java:118)
at com.android.org.bouncycastle.asn1.DefiniteLengthInputStream.read(DefiniteLengthInputStream.java:74)
at com.android.org.bouncycastle.util.io.Streams.readFully(Streams.java:49)
at com.android.org.bouncycastle.util.io.Streams.readFully(Streams.java:40)
at com.android.org.bouncycastle.asn1.ASN1InputStream.getBuffer(ASN1InputStream.java:384)
at com.android.org.bouncycastle.asn1.ASN1InputStream.createPrimitiveDERObject(ASN1InputStream.java:447)
at com.android.org.bouncycastle.asn1.ASN1InputStream.buildObject(ASN1InputStream.java:184)
at com.android.org.bouncycastle.asn1.ASN1InputStream.readObject(ASN1InputStream.java:272)
at com.android.org.bouncycastle.asn1.ASN1InputStream.buildEncodableVector(ASN1InputStream.java:193)
at com.android.org.bouncycastle.asn1.ASN1InputStream.buildDEREncodableVector(ASN1InputStream.java:204)
at com.android.org.bouncycastle.asn1.ASN1InputStream.buildObject(ASN1InputStream.java:173)
at com.android.org.bouncycastle.asn1.ASN1InputStream.readObject(ASN1InputStream.java:272)
at com.android.org.bouncycastle.asn1.ASN1InputStream.buildEncodableVector(ASN1InputStream.java:193)
at com.android.org.bouncycastle.asn1.ASN1InputStream.buildDEREncodableVector(ASN1InputStream.java:204)
at com.android.org.bouncycastle.asn1.ASN1InputStream.buildObject(ASN1InputStream.java:173)
at com.android.org.bouncycastle.asn1.ASN1InputStream.readObject(ASN1InputStream.java:272)
at com.android.org.bouncycastle.asn1.ASN1InputStream.buildEncodableVector(ASN1InputStream.java:193)
at com.android.org.bouncycastle.asn1.ASN1InputStream.buildDEREncodableVector(ASN1InputStream.java:204)
at com.android.org.bouncycastle.asn1.ASN1InputStream.buildObject(ASN1InputStream.java:173)
at com.android.org.bouncycastle.asn1.ASN1InputStream.readObject(ASN1InputStream.java:272)
at com.android.org.bouncycastle.asn1.ASN1InputStream.buildEncodableVector(ASN1InputStream.java:193)
at com.android.org.bouncycastle.asn1.ASN1InputStream.buildDEREncodableVector(ASN1InputStream.java:204)
at com.android.org.bouncycastle.asn1.ASN1InputStream.buildObject(ASN1InputStream.java:173)
at com.android.org.bouncycastle.asn1.ASN1InputStream.readObject(ASN1InputStream.java:272)
at com.android.org.bouncycastle.jce.provider.CertPathValidatorUtilities.getObject(CertPathValidatorUtilities.java:339)
at com.android.org.bouncycastle.jce.provider.CertPathValidatorUtilities.getExtensionValue(CertPathValidatorUtilities.java:325)
at com.android.org.bouncycastle.jce.provider.RFC3280CertPathUtilities.processCertD(RFC3280CertPathUtilities.java:1268)
at com.android.org.bouncycastle.jce.provider.PKIXCertPathValidatorSpi.engineValidate(PKIXCertPathValidatorSpi.java:310)
at com.sec.android.security.pkix.SecCertPathValidatorSpi.engineValidate(SecCertPathValidatorSpi.java:100)
at java.security.cert.CertPathValidator.validate(CertPathValidator.java:190)
at com.android.org.conscrypt.TrustManagerImpl.checkTrusted(TrustManagerImpl.java:295)
at com.android.org.conscrypt.TrustManagerImpl.checkServerTrusted(TrustManagerImpl.java:202)
at com.android.org.conscrypt.OpenSSLSocketImpl.verifyCertificateChain(OpenSSLSocketImpl.java:612)
at com.android.org.conscrypt.NativeCrypto.SSL_do_handshake(Native Method)
at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:406)
at com.android.okhttp.Connection.upgradeToTls(Connection.java:146)
at com.android.okhttp.Connection.connect(Connection.java:107)
at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:294)
at com.android.okhttp.internal.http.HttpEngine.sendSocketRequest(HttpEngine.java:255)
at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:206)
at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:345)
at com.android.okhttp.internal.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:89)
at com.android.okhttp.internal.http.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java:161)
at org.springframework.http.client.SimpleBufferingClientHttpRequest.org.springframework.http.client.ClientHttpResponse executeInternal(org.springframework.http.HttpHeaders,byte[])(SourceFile:76)
at org.springframework.http.client.AbstractBufferingClientHttpRequest.org.springframework.http.client.ClientHttpResponse executeInternal(org.springframework.http.HttpHeaders)(SourceFile:48)
at org.springframework.http.client.AbstractClientHttpRequest.org.springframework.http.client.ClientHttpResponse execute()(SourceFile:84)
at org.springframework.http.client.InterceptingClientHttpRequest$RequestExecution.org.springframework.http.client.ClientHttpResponse execute(org.springframework.http.HttpRequest,byte[])(SourceFile:91)
at com.myapplication.webapi.spring.interceptors.IonAuthenticationClientInterceptor.org.springframework.http.client.ClientHttpResponse intercept(org.springframework.http.HttpRequest,byte[],org.springframework.http.client.ClientHttpRequestExecution)(SourceFile:82)
at org.springframework.http.client.InterceptingClientHttpRequest$RequestExecution.org.springframework.http.client.ClientHttpResponse execute(org.springframework.http.HttpRequest,byte[])(SourceFile:81)
at org.springframework.http.client.InterceptingClientHttpRequest.org.springframework.http.client.ClientHttpResponse executeInternal(org.springframework.http.HttpHeaders,byte[])(SourceFile:67)
at org.springframework.http.client.AbstractBufferingClientHttpRequest.org.springframework.http.client.ClientHttpResponse executeInternal(org.springframework.http.HttpHeaders)(SourceFile:48)
//The stack below repeats about 100 times
at org.springframework.http.client.AbstractClientHttpRequest.org.springframework.http.client.ClientHttpResponse execute()(SourceFile:84)
at org.springframework.http.client.InterceptingClientHttpRequest$RequestExecution.org.springframework.http.client.ClientHttpResponse execute(org.springframework.http.HttpRequest,byte[])(SourceFile:91)
at com.myapplication.webapi.spring.interceptors.IonAuthenticationClientInterceptor.org.springframework.http.client.ClientHttpResponse intercept(org.springframework.http.HttpRequest,byte[],org.springframework.http.client.ClientHttpRequestExecution)(SourceFile:82)
at org.springframework.http.client.InterceptingClientHttpRequest$RequestExecution.org.springframework.http.client.ClientHttpResponse execute(org.springframework.http.HttpRequest,byte[])(SourceFile:81)
at org.springframework.http.client.InterceptingClientHttpRequest.org.springframework.http.client.ClientHttpResponse executeInternal(org.springframework.http.HttpHeaders,byte[])(SourceFile:67)
at org.springframework.http.client.AbstractBufferingClientHttpRequest.org.springframework.http.client.ClientHttpResponse executeInternal(org.springframework.http.HttpHeaders)(SourceFile:48)
//End of stack that repeats 100 times
at org.springframework.http.client.InterceptingClientHttpRequest$RequestExecution.org.springframework.http.client.ClientHttpResponse execute(org.springframework.http.HttpRequest,byte[])(SourceFile:91)
at com.myapplication.webapi.spring.interceptors.IonAuthenticationClientInterceptor.org.springframework.http.client.ClientHttpResponse intercept(org.springframework.http.HttpRequest,byte[],org.springframework.http.client.ClientHttpRequestExecution)(SourceFile:82)
at org.springframework.http.client.InterceptingClientHttpRequest$RequestExecution.org.springframework.http.client.ClientHttpResponse execute(org.springframework.http.HttpRequest,byte[])(SourceFile:81)
at org.springframework.http.client.InterceptingClientHttpRequest.org.springframework.http.client.ClientHttpResponse executeInternal(org.springframework.http.HttpHeaders,byte[])(SourceFile:67)
at org.springframework.http.client.AbstractBufferingClientHttpRequest.org.springframework.http.client.ClientHttpResponse executeInternal(org.springframework.http.HttpHeaders)(SourceFile:48)
at org.springframework.http.client.AbstractClientHttpRequest.org.springframework.http.client.ClientHttpResponse execute()(SourceFile:84)
at org.springframework.http.client.InterceptingClientHttpRequest$RequestExecution.org.springframework.http.client.ClientHttpResponse execute(org.springframework.http.HttpRequest,byte[])(SourceFile:91)
at com.myapplication.webapi.spring.interceptors.IonAuthenticationClientInterceptor.org.springframework.http.client.ClientHttpResponse intercept(org.springframework.http.HttpRequest,byte[],org.springframework.http.client.ClientHttpRequestExecution)(SourceFile:82)
at org.springframework.http.client.InterceptingClientHttpRequest$RequestExecution.org.springframework.http.client.ClientHttpResponse execute(org.springframework.http.HttpRequest,byte[])(SourceFile:81)
at org.springframework.http.client.InterceptingClientHttpRequest.org.springframework.http.client.ClientHttpResponse executeInternal(org.springframework.http.HttpHeaders,byte[])(SourceFile:67)
at org.springframework.http.client.AbstractBufferingClientHttpRequest.org.springframework.http.client.ClientHttpResponse executeInternal(org.springframework.http.HttpHeaders)(SourceFile:48)
at org.springframework.http.client.AbstractClientHttpRequest.org.springframework.http.client.ClientHttpResponse execute()(SourceFile:84)
at org.springframework.web.client.RestTemplate.java.lang.Object doExecute(java.net.URI,org.springframework.http.HttpMethod,org.springframework.web.client.RequestCallback,org.springframework.web.client.ResponseExtractor)(SourceFile:536)
at org.springframework.web.client.RestTemplate.java.lang.Object execute(java.lang.String,org.springframework.http.HttpMethod,org.springframework.web.client.RequestCallback,org.springframework.web.client.ResponseExtractor,java.util.Map)(SourceFile:506)
at org.springframework.web.client.RestTemplate.org.springframework.http.ResponseEntity exchange(java.lang.String,org.springframework.http.HttpMethod,org.springframework.http.HttpEntity,java.lang.Class,java.util.Map)(SourceFile:455)
at com.myapplication.webapi.smartclients.SynchronizationClient_.org.springframework.http.ResponseEntity requestUpdateFile(long,long)(SourceFile:95)
at com.myapplication.services.synchronization.SynchronizationTask$2$1.org.springframework.http.ResponseEntity call()(SourceFile:514)
at com.myapplication.services.synchronization.SynchronizationTask$2$1.java.lang.Object call()(SourceFile:509)
at com.myapplication.managers.rest.RestManager$RestRequest.java.lang.Object execute()(SourceFile:110)
at com.myapplication.managers.rest.RestManager.java.lang.Object executeRequest(java.lang.String,int,com.myapplication.webapi.spring.RestErrorProcessor,java.util.concurrent.Callable)(SourceFile:67)
at com.myapplication.services.synchronization.SynchronizationTask$2.void run()(SourceFile:506)
at java.lang.Thread.run(Thread.java:841)
我在控制台上没有任何错误。
我一定错过了什么......
答案 0 :(得分:2)
问题是,当目标元素尚未加载时,您正尝试初始化滑块。此外,当您在超时内显示div.pup
时,您应该在那里初始化swiper。
您可以改进的其他方面是您不需要等待分别加载DOM和内容。在这种情况下,只等待DOM就足够了。
您的代码应如下所示(jsFiddle):
$(function(){
$("div#slidex").append('<div class="pup disable"><div class="swiper-container"><div class="swiper-wrapper"><div class="swiper-slide"><img src="http://seveloff.com/test/images/1.jpg" alt="pro group 1"></div><div class="swiper-slide"><img src="http://seveloff.com/test/images/2.jpg" alt="pro group 2"></div><div class="swiper-slide"><img src="http://seveloff.com/test/images/3.jpg" alt="pro group 3"></div><div class="swiper-slide"><img src="http://seveloff.com/test/images/4.jpg" alt="pro group 4"></div></div> <div class="swiper-pagination"></div></div><img id="x" src="http://cmsresources.windowsphone.com/windowsphone/en-us/How-to/wp7/inline/basic-icon-x.png"> </div>');
setTimeout(function() {
$("div.pup").fadeIn(200).addClass("active");
new Swiper('.swiper-container', {
pagination: '.swiper-pagination',
nextButton: '.swiper-button-next',
prevButton: '.swiper-button-prev',
slidesPerView: 1,
paginationClickable: true,
spaceBetween: 30,
loop: true,
autoplay: 2500,
autoplayDisableOnInteraction: false,
effect: 'fade'
});
}, 3000);
$('#x').on('click', function() {
$("div.pup").fadeOut(300).addClass("disable");
});
});