jquery 不继续到下一页

发布于 2024-11-09 17:58:40 字数 1478 浏览 0 评论 0原文

我有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 中工作正常。

i have jquery, but it is not going to next page, it always display images and waits, never proceed to next page.

HTML code:

<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 view source:

<SCRIPT type="text/javascript">  
   var $ = jQuery.noConflict();  
   $('.toHide').show().doTimeout(100,function() { 
   $('.toHide').find('safeForma3').submit();});
</SCRIPT>

wicket code:

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>");

i have tried with: $('.toHide').find('form').submit();});. But still no use.

After chaging $('.toHide') to $('#toHide'), page is going ot next page, but animation is not happening in IE6/7, it works fine in FF.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

别想她 2024-11-16 17:58:40

“toHide”

具有该字符串,因为它是 id 值,而不是它的类,因此您需要:

 $('#toHide')

选择器“.toHide”查找带有“的元素” toHide”作为类的一部分,这样就根本找不到您的

要查找表格,您可以使用

 $('#toHide form').submit();

The "toHide" <div> has that string as it's id value, not it's class, so you need:

 $('#toHide')

The selector ".toHide" looks for an element with "toHide" as part of the class, so that wouldn't find your <div> at all.

To find the form, you'd use

 $('#toHide form').submit();
过气美图社 2024-11-16 17:58:40

我认为你应该尝试这个:

$('#toHide').find('form').submit();

或者,如果表单上有一个 ID(我不熟悉 Wicket),你可以使用:

$('#safeForm').submit();

ID 选择器使用“#”字符,而不是“.”,这是类选择器前缀。

I think you should try this:

$('#toHide').find('form').submit();

Or if the form has an ID on it (I'm not familiar with Wicket) you can just use:

$('#safeForm').submit();

The ID selector uses a '#' charactor, not a '.', which is the class selector prefix.

凉城凉梦凉人心 2024-11-16 17:58:40

HTML 中没有名为“safeForm15”的 id,这正是 setTimeout 尝试选择的 ID。事实上,该表单具有 ID 命名空间,我认为这从一开始就是非法的。

无论如何,快速解决方法是取消“toHide”,并删除 component.getMarkupId 位。

$('#toHide').find('form').submit();

补充:

您需要将其更改

  buffer.append("  setTimeout(function(){ $(\"#").append(component.getMarkupId()).append("\").submit()}, 100);\n"); 

为:

  buffer.append("  setTimeout(function(){$('#toHide').find('form').submit();}, 100);\n"); 

There is no id named 'safeForm15' in your HTML, which is what your setTimeout is trying to select. In fact, the form has ID namespaced, which I believe is illegal to begin with.

Regardless, the quick fix is to cue off of 'toHide', and get rid of the component.getMarkupId bit.

$('#toHide').find('form').submit();

Added:

You need to change this:

  buffer.append("  setTimeout(function(){ $(\"#").append(component.getMarkupId()).append("\").submit()}, 100);\n"); 

to this:

  buffer.append("  setTimeout(function(){$('#toHide').find('form').submit();}, 100);\n"); 
悲凉≈ 2024-11-16 17:58:40

这是 IE 的问题,如果您有一个不可见的 GIF,然后将其设置为可见,则动画不起作用。

最好的办法就是使用一个空图像标签,例如 ,然后当您希望它可见时将 src 设置为正确的路径即

如果你这样做的话应该会起作用。

编辑

你可以这样做:

<SCRIPT type="text/javascript">  
   var $ = jQuery.noConflict();       
   $('#toHide').show();
   $('#loadingImg').attr('src', 'img/load.gif');
   setTimeout(function() {
       $('#toHide').find('safeForma3').submit();
   }, 100);
</SCRIPT>

html代码:

<div id="toHide" class="pb-text-align-center">
    <img id="loadingImg" style="display:inline" src="" />
    <form wicket:id="safeForm" class="clearfix">
        <input type="hidden" wicket:id="submitted" value="false" />
    </form>
</div>

尝试一下,但可能需要一些摆弄。

This is a problem with IE, if you have a GIF that is not visible and then set it to visible the animation doesn't work.

Best thing to do is just used an empty image tag like this <img src='' /> and then when you want it to become visible set the src to the correct path i.e. <img src='AnimatingImg.gif' />.

It should work if you do it this way.

EDIT

You can do it like this:

<SCRIPT type="text/javascript">  
   var $ = jQuery.noConflict();       
   $('#toHide').show();
   $('#loadingImg').attr('src', 'img/load.gif');
   setTimeout(function() {
       $('#toHide').find('safeForma3').submit();
   }, 100);
</SCRIPT>

html code:

<div id="toHide" class="pb-text-align-center">
    <img id="loadingImg" style="display:inline" src="" />
    <form wicket:id="safeForm" class="clearfix">
        <input type="hidden" wicket:id="submitted" value="false" />
    </form>
</div>

Try that, might want a bit of fiddling though.

终难愈 2024-11-16 17:58:40

其他人提到了您的选择器的问题。

但是,此代码也赤裸裸地出现在两个 script 标记之间。这意味着它们一被解析就会被执行。这意味着它们可以在整个 DOM 加载之前执行,从而使它们无效。

你需要使用这样的东西:

<SCRIPT type="text/javascript">  
   var $ = jQuery.noConflict();  
   $(document).ready(function(){
       $('#toHide').show().doTimeout(100,function() { 
           $('#safeForma3').submit();
       });
   });
</SCRIPT>

Others have mentioned the problem with your selector.

However, this code also appears naked between two script tags. This means that they will be executed as soon as they are parsed. This means that they could be executed before the whole DOM is loaded, rendering them ineffective.

You need to use something like this:

<SCRIPT type="text/javascript">  
   var $ = jQuery.noConflict();  
   $(document).ready(function(){
       $('#toHide').show().doTimeout(100,function() { 
           $('#safeForma3').submit();
       });
   });
</SCRIPT>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文