开发者

Jquery modal window problem

All,

Can u please tell me whats wrong with the following code.I am trying to open a modal window here and the contents of it is a text box.

Also i get the java script error .dialog is not a function.

<html>
    <head>
        <script src="http://code.jquery.com/jquery-latest.js"></script>

        <script>
            $(document).ready(function() {
                $("#a").click( function(e) {
                    e.preventDefault();
                    var html='<div id="e_ls" style="overflow:auto;text-align:justify"><textarea rows="10" cols="10"></textarea></div>';

                    $e_ls = jQuery('#e_ls');
                    $e_ls.html(html);
                    $("#e_ls").dialog("open");
                }); 
        开发者_如何学运维    });
        </script>
    </head>
    <a href="" id="a" >a</a>
</html>

Thanks....


Its more than just the Jquery UI File Missing. You are pulling it in incorrectly. Try:

<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js" type="text/javascript"></script>
<script>
                $(document).ready(function() {
                    $("#e_ls").dialog({ autoOpen: false });
                    $("#a").click( function(e) {
                        e.preventDefault();
                        $e_ls = jQuery('#e_ls');
                        $("#e_ls").dialog('open');
                    }); 
                });
            </script>
</head>
<body>
<a href="" id="a" >a</a>
<div id="e_ls" style="overflow:auto;text-align:justify">
  <textarea rows="10" cols="10"></textarea>
</div>
</body>
</html>

With the above the e_ls is hidden by default and only called when you ask. Note you do not need the preventDefault() if you put no href in your tag or use a different tag. the preventDefault is only required because you have an active link which also is incorrect...

Ideally you should use a

or a if you want to format it like a link you can use CSS <a id="a" style="cursor:pointer; text-decoration: underline; color:00F">a</a>


You need to download and include the jqueryUI code from http://www.jqueryui.com


You need the jQueryui javascript file.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜