]> source.dussan.org Git - jquery-ui.git/commitdiff
Menubar: Trigger select event after running all other methods. Allows the select...
authorJörn Zaefferer <joern.zaefferer@gmail.com>
Wed, 13 Jul 2011 15:03:25 +0000 (11:03 -0400)
committerJörn Zaefferer <joern.zaefferer@gmail.com>
Wed, 13 Jul 2011 15:03:31 +0000 (11:03 -0400)
demos/menubar/default.html
ui/jquery.ui.menubar.js

index 6bd67b64af62f38a43379a6efef7ad845774c66d..adee4afc90f3fb4deeb1bdfa2e3c0ffa58738ef7 100644 (file)
        <script src="../../ui/jquery.ui.menubar.js"></script>
        <script>
        $(function() {
+               function select(event, ui) {
+                       $("<div/>").text("Selected: " + ui.item.text()).appendTo("#log");
+                       if (ui.item.text() == 'Quit') {
+                               $(this).menubar('destroy');
+                       }
+               }
                $("#bar1").menubar({
                        position: {
                                within: $("#demo-frame").add(window).first()
                        },
-                       select: function(event, ui) {
-                               $("<div/>").text("Selected: " + ui.item.text()).appendTo("#log");
-                       }
+                       select: select
                });
 
                $(".menubar-icons").menubar({
@@ -29,9 +33,7 @@
                        position: {
                                within: $("#demo-frame").add(window).first()
                        },
-                       select: function(event, ui) {
-                               $("<div/>").text("Selected: " + ui.item.text()).appendTo("#log");
-                       }
+                       select: select
                });
        });
        </script>
index 3df6d9a53df793e03e094d02a9b1356fc17064d9..e28ea3e3c1ca9ad7e87266c2bf4e05701ac33ca4 100644 (file)
@@ -49,10 +49,10 @@ $.widget( "ui.menubar", {
                                },
                                select: function( event, ui ) {
                                        ui.item.parents( "ul.ui-menu:last" ).hide();
-                                       that._trigger( "select", event, ui );
                                        that._close();
                                        // TODO what is this targetting? there's probably a better way to access it
                                        $(event.target).prev().focus();
+                                       that._trigger( "select", event, ui );
                                }
                        })
                        .hide()
@@ -94,7 +94,7 @@ $.widget( "ui.menubar", {
                                        if( that.options.autoExpand ) {
                                                clearTimeout( that.timer );
                                        }
-                                       
+
                                        that._open( event, menu );
                                }
                        })
@@ -120,7 +120,7 @@ $.widget( "ui.menubar", {
                        .attr( "role", "menuitem" )
                        .attr( "aria-haspopup", "true" )
                        .wrapInner( "<span class='ui-button-text'></span>" );
-                       
+
                        if ( that.options.autoExpand ) {
                                input.bind( "mouseleave.menubar", function( event ) {
                                        that.timer = setTimeout( function() {