I'm a bit old school so I avoid anonymous functions if possible - I find the code more readable and easier to maintain a year from now when I have to tweak something.
I want to incorporate the Click function into the Start function and rather than repeat the code I thought I'd just call the function. However when called that way the function has no concept of $(this)
How do I call the click function and still have it work?
function btchDragStart(ev, dd) {
console.log('btchDragStart');
btchBoxClick();
}
function btchBoxClick(){
console.log('btchBoxClick');
$('.btchPanel').hide();
var panelName = $(this).attr('id').substr(0,boxId.length-3);
$('#'+panelName).show();
$(this).css('zIndex', z++);
}
function btchDragged(ev, dd) {
console.log('btchDragged');
}
function btchDragEnd(ev) {
console.log('btchDragEnd');
}
//----------------------------------------------------------
//dragging and resizing
//----------------------------------------------------------
$('.drag')
.drag("start", btchDragStart)
.click(btchBoxClick)
.drag(btchDragged)
.drag('dragend', btchDragEnd);