Reputation: 97
I am using the following for a double-tap/single tap of a DOM element.
$(selector).doubletap(
/** doubletap-dblclick callback */
function(event){
var $this = $(event.currentTarget);
},
/** touch-click callback (touch) */
function(event){
doSingleClick(this)
},
/** doubletap-dblclick delay (default is 500 ms) */
400
);
Another function I call from the above :
function doSingleClick(but) {
var $but = $(but);
if($but.closest("#domElementId").length < 1)
return;
//"I have more code here to handle the if statement"
}
The doSingleClick function never gets past the return b/c the value of $but never gets correctly defined. My assumption is that I am not passing parameters correctly. Where is my issue?
Upvotes: 0
Views: 138
Reputation: 484
Looks like you pulled this code from here:
http://appcropolis.com/implementing-doubletap-on-iphones-and-ipads/
Looking at the code, the functions you are providing to .doubletap() are invoked on an event callback from the browser, without the benefit of the jQuery selector. The 'this' in:
function(event){
doSingleClick(this)
},
is likely the Window context, not the element you are expecting. The simplest approach to fixing it is using the current element as the input:
function(event){
doSingleClick(event.currentTarget)
},
which is what the doubletap/click function is already doing with the $this = $(event.currentTarget)
Hope that helps.
Upvotes: 1