jquery use of :last and val()

Posted by dole doug on Stack Overflow See other posts from Stack Overflow or by dole doug
Published on 2012-07-07T09:12:45Z Indexed on 2012/07/07 9:15 UTC
Read the original article Hit count: 321

Filed under:

I'm trying to run the code from http://jsfiddle.net/ddole/AC5mP/13/ on my machine and the approach I've use is below or here.

Do you know why that code doesn't work on my machine. Firebug doesn't help me and I can't solve the problem. I think that I need another pair of eyes :(((

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>jQuery UI Dialog - Modal form</title>
    <link type="text/css" href="css/ui-lightness/jquery-ui-1.8.21.custom.css" rel="stylesheet" />
    <script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>
    <script type="text/javascript" src="js/jquery-ui-1.8.21.custom.min.js"></script>
    <script  type="text/javascript" >
        jQuery(function($) {
            $('.helpDialog').hide();
            $('.helpButton').each(function() {  
                $.data(this, 'dialog',
                $(this).next('.helpDialog').dialog({
                    autoOpen: false,  
                    modal: true,  
                    width: 300,  
                    height: 250,
                    buttons: {
                        "Save": function() {
                            alert($('.helpText:last').val());
                            $(this).dialog( "close" );
                        },
                        Cancel: function() {
                            $(this).dialog( "close" );
                        }
                    }
                })
            );  
            }).click(function() {  
                $.data(this, 'dialog').dialog('open');  
                return false;  
            });  
        });  
    </script>
</head>
<body>

    <span class="helpButton">Button</span>
    <div class="helpDialog">
        <input type="text" class="helpText" />
    </div>

    <span class="helpButton">Button 2</span>
    <div class="helpDialog">
        <input type="text" class="helpText" />
    </div>

    <span class="helpButton">Button 3</span>
    <div class="helpDialog">
        <input type="text" class="helpText" />
    </div>

    <span class="helpButton">Button 4</span>
    <div class="helpDialog">
        <input type="text" class="helpText" />
    </div>

    <span class="helpButton">Button 5</span>
    <div class="helpDialog">
        <input type="text" class="helpText" />
    </div>    </body>

© Stack Overflow or respective owner

Related posts about jquery-ui