$.fn.bind and fn.apply() problems on draggables
Hi,
Not sure wether this should be here on in the UI (since it's revolves around both, feel free to move if you think I've posted it wrongly)
It basically wrap everything in a try/catch letting you catch errors like this:
- $.handleErrors(function(e){
- console.log("an error occurred");
- console.log(e);
- });
However, this does not work for draggables or resizables (but for everything else). If you start to drag/resize an element, it doesn't stop on mouse up (making the drag forever).
It appears as if the ofn.apply() doesn't work on draggable/resizable.
Specifically (shortened):
- ofn = fn;
- wfn = function() {
- ofn.apply(this, arguments);
- };
- fn = wfn;
But for all other events:
- $.fn.bind = function(type, data, fn) {
- var ofn, wfn;
- if (!fn && data && $.isFunction(data)) {
- fn = data;
- data = undefined;
- }
- if (fn && type.indexOf("error") === -1) {
- ofn = fn;
- wfn = function() {
- try {
- ofn.apply(this, arguments);
- } catch(e) {
- handler(e);
- return false;
- }
- };
- fn = wfn;
- }
- return jbind.call(this, type, data, fn);
I'm pretty much lost here, and I can't find any resource saying why this shouldn't work (I can't even find anyone who has the same issues)
So my questions are:
1. Does the above method seem like an OK way to catch errors with jQuery (or is it to resource expensive)
2. Has anyone experienced the same issue (and fixed it)
3. Do I misunderstand something and I should simply not call this on draggable events
Regards,
NIklas