I'm sure i'm doing something terribly stupid for this not to work, but I can't get my shift event to fire. I've tried both:
$('.ShowCannedReport_UserFilterDropdown').each(function (index, element) {
$(element).bind('click', function (event) {
if (!event.shiftKey && !event.ctrlKey) {
ShowCannedReport_UserFilter_Blur(this, event);
}
else {
ShowCannedReport_UserFilterWithShiftHeld = this;
}
});
and:
$('.ShowCannedReport_UserFilterDropdown').each(function (index, element) {
$(element).click(function (event) {
if (!event.shiftKey && !event.ctrlKey) {
ShowCannedReport_UserFilter_Blur(this, event);
}
else {
ShowCannedReport_UserFilterWithShiftHeld = this;
}
});
});
Both of these show the event.shiftkey as undefined. Any idea as to what i'm doing wrong?
ShowCannedReport_UserFilterDropdown is a multiselect dropdown and the click event is firing on both versions, but the shiftkey event is never registered.
Can you be sure that your initial selector is working? I.e:
$('.ShowCannedReport_UserFilterDropdown').length; //is this >0 ?
Is the code inside the document ready event handler?
I've set up a jsFiddle that mimics what you are trying to achive, and all works ok: http://jsfiddle.net/xT4ke/
Also, why are you iterating through each item when jQuery does that for you, This should suffice:
$('.ShowCannedReport_UserFilterDropdown').click(function (event) {
if (!event.shiftKey && !event.ctrlKey) {
ShowCannedReport_UserFilter_Blur(this, event);
}
else {
ShowCannedReport_UserFilterWithShiftHeld = this;
}
});
});