I’m getting a weird error message inside mobile safari on iOS:
“TypeError: ‘[object Object]’ is not a valid argument for ‘Function.prototype.apply'”.
The code which triggers this works fine in Chrome (after adjusting the event type to click instead of tap).
// task-item visualization
$(".task-item").live('touchend',function(e){
app.toggleTask.apply(this,e);
});
I used to have .toggleTask direct as an anonymous function inside the event binder, but I’m trying to refactor out all of this stuff so I can reuse it. What am I missing? I’m passing this in the event context to the function with apply, but it doesn’t seem to like this argument in mobile safari (guessing same error in phonegap, but can’t see it).
The project is using Zepto 0.7, phonegap 1.2 and is on an iOS5 ipad.
According to MDN, the apply method takes an array as the second argument. You want to try: