Let's assume i have the following control :
Clickable Label
This is the hidden content of my DIV Window
By default the wndSL has
style= " display:none; background-color: blue; height:500px; width:590px;"
I am able to show the wndSL when I click either slControlLabel or slControlDropDown.
However I also need to hide it when I click either on the slControlLabel or slControlDropDown or anywhere outside the wndSL outside .
Can anyone help me how to figure out how to hide it, clicking anywhere outside my wndSL.
This is what I have so far... and I need to add the piece to hide it whenever i click outside the window
Thanks
$('.slControlLabel, .slControlDropDown').bind('click',function(event){
alert('This will open the wndSL');
$('#wndSL').show();
});
New Problem Revision 2
Here is the DIV i have now and as you will see I have more controls in there... so the origiinal answer does not work anymore because, when I click on the control within the DIV, it still closes the DIV.... So although my original request was to close when you click outside the DIV works , when i addded controls within the DIV, my condition to hide does not work... How can I tweak it so that anything within the DIV when clicked will not close the window (except the close button icoRedX.gif on the header )
This is my control
Select a saved Shopping List to open. The list you already have open will be automatically saved
Master Shopping List
Updated August 10, 2011
16 items
Audrey's Birthday Party
Shopped August 2, 2011 for $49.11
11 items
Monthly Household Supplies
Updated February 22, 2011
8 items
This is the JS
function OnPageLoad(){
window.$ = $telerik.$;
var t;
$(document).ready(function () {
$('.slControlLabel, .slControlDropDown').bind('click',function(event){
$('#wndShoppingList').show();
event.stopPropagation();
});
// OnClick Event outside the wndShoppinglist.
// $('html').click(function(event){ Tried this as well
if((event.target.id != 'wndShoppingList')){ // This used to work but after adding controls in the DIV, this returns the ID of the controls within the DIV
alert('click on body '+ event.target.id)
alert('about to hide')
$('#wndShoppingList').hide();
});
}); //End $(document).ready()
}
Sys.Application.add_load(OnPageLoad);
No comments:
Post a Comment