【发布时间】:2011-05-26 14:08:38
【问题描述】:
我有 jquery,但它不会进入下一页,它总是显示图像并等待,永远不会进入下一页。
HTML 代码:
<div id="toHide" class="pb-text-align-center">
<img style="display: inline" src="img/load.gif" />
<form wicket:id="safeForm" class="clearfix">
<input type="hidden" wicket:id="submitted" value="false" />
</form>
</div>
HTML 查看源代码:
<SCRIPT type="text/javascript">
var $ = jQuery.noConflict();
$('.toHide').show().doTimeout(100,function() {
$('.toHide').find('safeForma3').submit();});
</SCRIPT>
检票口代码:
static private class SafeSubmitBehaviour extends AbstractBehavior{
public void onRendered( Component component ) {
super.onRendered( component );
StringBuffer buffer = new StringBuffer(200);
buffer.append("<script type=\"text/javascript\" >\n");
buffer.append("var $ = jQuery.noConflict();\n ");
buffer.append(" $('.toHide').show().doTimeout(100,function() { $('.toHide').find('");
buffer.append(component.getMarkupId()).append("').submit();});\n</script>");
component.getResponse().write(buffer);
}
}
buffer.append(component.getMarkupId()).append("').submit();});\n</script>");
我尝试过:$('.toHide').find('form').submit();});。但是还是没用。
将 $('.toHide') 更改为 $('#toHide') 后,页面将转到下一页,但在 IE6/7 中没有出现动画,在 FF 中可以正常工作。
【问题讨论】:
-
我怀疑问题出在 setTimeout 上。它在 IE 中运行良好。提供相同类型功能的库将使用 jQuery。此外,如果您提供最少的代码来重现仅 HTML/JS 的问题,您更有可能得到答案。
-
你在 FF 中验证,你会得到差异
-
我认为这与 jquery 无关。这似乎是css的问题。建议:将页面的这一部分保存在本地硬盘上(来自浏览器)并尝试显示图像。
-
确认渲染的 wicket:id 和脚本是一样的。我发现确实存在
component.getMarkupId()在构造过程中返回不同值的情况。例如,构造函数中的getMarkupId()与onBeforeRender()中的getMarkupId()不同。另外,我想你已经完成了component.setOutputMarkupId(true)?
标签: javascript jquery wicket