How to open dialogs depending on what tabs are active in jQuery?
I have this setup, http://jsfiddle.net/patrioticcow/LQg7W/34/.
How c开发者_如何学编程an the dialogs opened depending on what tabs are active?
Something is missing there..
var theSelectedTab = 0;
$( "#tabMe" ).tabs({ select: function(event, ui) {
theSelectedTab = parseFloat(ui.index);
}
});
$('#edit1').click(function() {
$('#edit_'+(theSelectedTab+1)).dialog('open');
});
});
Tested: it worked.
You should only need to do this?
if (theSelectedTab == 0) {
$("#edit_1").dialog("open");
} else if (theSelectedTab == 1) {
$("#edit_2").dialog("open");
}
In the if(){}
block you were assigning a live()
handler but not actually triggering anything.
Adjusted jsfiddle.
精彩评论