I have written a library of useful 'mobile' events (available here). It essentially unifies touch events so that a single event can be bound to an element, and it will trigger regardless of the user's device (i.e. mobile or desktop).
The code has been working well, but while debugging a user's problem, I noticed that the library no longer functions when jQuery 1.9.0 is used (all previous versions of jQuery don't cause a problem).
The problematic code is as follows:
// Add Event shortcuts:
$.each(('tapstart tapend tap singletap doubletap taphold swipe swipeup swiperight swipedown swipeleft scrollstart scrollend orientationchange').split(' '), function(i, name) {
$.fn[name] = function(fn)
{
return fn ? this.bind(name, fn) : this.trigger(name);
};
$.attrFn[name] = true;
});
The error Uncaught TypeError: Cannot set property 'tapstart' of undefined
on the following line:
$.attrFn[name] = true;
Can anyone point me in the direction of producing a fix for this?
I have put together 2 jsFiddle demos to show the problem:
If I define $.attrFn
, this fixes code for the swipe*
events, but then causes problems with others such as tap
and doubletap
. For example, binding tap
now produces the error: Uncaught TypeError: Cannot call method 'call' of undefined
, with the problematic line being:
$.event.handle.call( obj, event );
Once again, there are two jsFiddles for reference:
$.attrFn = $.attrFn || {};
fix)That object (.attrFn
) was just a stub in 1.8; it's gone in 1.9.
If your code worked in 1.8, you should be able to add
$.attrFn = $.attrFn || {};
somewhere to fix it.
From the jQuery 1.9 Release Notes
Other undocumented properties and methods
The following internal properties and methods were never documented and have been removed in 1.9. Any code that depends on them should be rewritten.
- jQuery.deletedIds
- jQuery.uuid
- jQuery.attrFn
- jQuery.clean()
- jQuery.event.handle()
- jQuery.offset.bodyOffset()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With