强制jQuery ready块在所有其他ready块之后运行

编程入门 行业动态 更新时间:2024-10-24 01:54:50
本文介绍了强制jQuery ready块在所有其他ready块之后运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

是否有可能在所有其他代码都执行完之后执行一个jQuery ready块.

Is it possible to have one jQuery ready block executed after all others have done so.

我的主页上有这个...

I have this in my master page ...

<script type="text/javascript"> $(document).ready(function() { $("input[type='text']:enabled:first", document.forms[0]).focus().select(); }); </script>

这是我其他页面之一...

and this in one of my other pages ...

<script type="text/javascript"> $(document).ready(function() { $('textarea.message-body').wysiwyg(); }); </script>

我看到的问题是第一个块在第二个块之前执行,这导致Tab键出现问题.发生的事情是,当我按下Tab键时,键盘焦点移到了浏览器中的地址栏.我已经稍微更改了代码以使其在我的母版页中...

The problem I am seeing is that the first block is executed before the second block, which is causing a problem with the tab key. What's happening is that the keyboard focus goes to the address bar in my browser when I press the tab key. I've changed the code slightly to have this in my master page ...

<script type="text/javascript"> $(document).ready(function() { var bodies = $('textarea.message-body'); if (bodies.length > 0) { bodies.wysiwyg(); } $("input[type='text']:enabled:first", document.forms[0]).focus().select(); }); </script>

并完全取消其他准备就绪的块.这样可以使Tab键正常工作,并将焦点设置在我的文本区域上.

and do away with the other ready block completely. Doing that makes the tab key work properly, and set the focus onto my textarea.

我宁愿我的母版页中没有特定于页面的代码.

I'd rather not have page specific code in my master page.

那么,有没有办法让我的文本框焦点代码在所见即所得代码之后运行?

So, is there a way to make my textbox focusing code run after the wysiwyg code?

推荐答案

这是我使用的解决方案.

This is the solution I went with.

在我的母版页中,我有这个...

In my master page I have this...

<script type="text/javascript"> <!-- $(document).ready(function() { if (typeof (OnLoad) != "undefined") { OnLoad(); } $("input[type='text']:enabled:first", document.forms[0]).focus().select(); }); //--> </script>

在我的详细信息页面中,我有这个...

and in my detail pages I have this...

<script type="text/javascript"> <!-- function OnLoad() { $('textarea.message-body').wysiwyg(); } //--> </script>

更多推荐

强制jQuery ready块在所有其他ready块之后运行

本文发布于:2023-10-14 11:58:58,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1490998.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:jQuery   ready

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!