views:

22

answers:

1

i am using the jQueryUI Position Utilities, but i don't know why it not run on $(document).ready(), if i use firebug and execute the position(); again manually, it work fine.

Update: I try that code only not work on IE8, it work on firefox and chrome.

The code on : http://jsbin.com/owoya3/edit

<!DOCTYPE html>
<html>
<head>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"&gt;&lt;/script&gt;
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.0/jquery-ui.min.js"&gt;&lt;/script&gt;
    <style type="text/css">
        #Parent
        {
             width: 300px; 
             background-color: #999; 
             border: 1px solid #aaa;
        }
        #Parent  tr  td 
        {
            width: 60px; 
            height: 60px;
             text-align: center; 
             border: 1px solid #aaa;
        }
        div.positionable
        {
            width: 60px;
            height: 60px;
            position: absolute;
            display: block;
            right: 0;
            bottom: 0;
            background-color: #bcd5e6;
            text-align: center;
        }
    </style>
    <script type="text/javascript">

        function position() {
            $("#BoxA").position({
                of: $("#CellA"),
                my: 'left top',
                at: 'left top',
                offset: '0 0'
            });
        }


        $(document).ready(function () {
            $(".positionable").css("opacity", 0.5);
            position();
        });
    </script>
    <title></title>
</head>
<body>
    <table id="Parent">
        <tr>
            <td id="CellA">A</td>
            <td id="CellB">B</td>
        </tr>
    </table>
    <div id="BoxA" class="positionable">
        <p>A(2)</p>
    </div>
    <div id="BoxB" class="positionable">
        <p>B(2)</p>
    </div>
</body>
</html>
+1  A: 

The problem is fixed, maybe bug of IE or jquery, but in quick , i do it in a dirty way, i call position() twice can be fix.

    $(document).ready(function () {
        position();
        position(); //YES, 2 times.
    });
SilverNight