mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Menubar: Trigger select event after running all other methods. Allows the select-handler to destroy the widget without errors.
This commit is contained in:
parent
06676f4696
commit
7856b264a2
@ -13,13 +13,17 @@
|
|||||||
<script src="../../ui/jquery.ui.menubar.js"></script>
|
<script src="../../ui/jquery.ui.menubar.js"></script>
|
||||||
<script>
|
<script>
|
||||||
$(function() {
|
$(function() {
|
||||||
|
function select(event, ui) {
|
||||||
|
$("<div/>").text("Selected: " + ui.item.text()).appendTo("#log");
|
||||||
|
if (ui.item.text() == 'Quit') {
|
||||||
|
$(this).menubar('destroy');
|
||||||
|
}
|
||||||
|
}
|
||||||
$("#bar1").menubar({
|
$("#bar1").menubar({
|
||||||
position: {
|
position: {
|
||||||
within: $("#demo-frame").add(window).first()
|
within: $("#demo-frame").add(window).first()
|
||||||
},
|
},
|
||||||
select: function(event, ui) {
|
select: select
|
||||||
$("<div/>").text("Selected: " + ui.item.text()).appendTo("#log");
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$(".menubar-icons").menubar({
|
$(".menubar-icons").menubar({
|
||||||
@ -29,9 +33,7 @@
|
|||||||
position: {
|
position: {
|
||||||
within: $("#demo-frame").add(window).first()
|
within: $("#demo-frame").add(window).first()
|
||||||
},
|
},
|
||||||
select: function(event, ui) {
|
select: select
|
||||||
$("<div/>").text("Selected: " + ui.item.text()).appendTo("#log");
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
2
ui/jquery.ui.menubar.js
vendored
2
ui/jquery.ui.menubar.js
vendored
@ -49,10 +49,10 @@ $.widget( "ui.menubar", {
|
|||||||
},
|
},
|
||||||
select: function( event, ui ) {
|
select: function( event, ui ) {
|
||||||
ui.item.parents( "ul.ui-menu:last" ).hide();
|
ui.item.parents( "ul.ui-menu:last" ).hide();
|
||||||
that._trigger( "select", event, ui );
|
|
||||||
that._close();
|
that._close();
|
||||||
// TODO what is this targetting? there's probably a better way to access it
|
// TODO what is this targetting? there's probably a better way to access it
|
||||||
$(event.target).prev().focus();
|
$(event.target).prev().focus();
|
||||||
|
that._trigger( "select", event, ui );
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.hide()
|
.hide()
|
||||||
|
Loading…
Reference in New Issue
Block a user