强制jQuery ready块在所有其他ready块之后运行 [英] forcing a jQuery ready block to run after all other ready blocks

查看:70
本文介绍了强制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块之后运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆