Craga89/qTip2 — Issue #318: JS error when using latest qTip with jQuery 1.4.4
Author: m4olivei
Created: 2012-02-22 05:08:43+00:00
State: open

I'm using qTip with the latest build of qTip v2 from the download on the site with jQuery 1.4.4. I am using the unfocus event for the hide options and was getting an error like

q.replace is not a function

I then used the uncompressed versions of qTip and jQuery and traced the issue down to line 556 in my build, or this block of code:

```javascript
// Hide tooltip on document mousedown if unfocus events are enabled
if(('' + options.hide.event).indexOf('unfocus') > -1) {
targets.document.bind('mousedown'+namespace, function(event) {
var $target = $(event.target),
enabled = !tooltip.hasClass(disabled) && tooltip.is(':visible'),
isAncestor = $target.parents(selector).filter(tooltip[0]).length > 0;

if($target[0] !== tooltip[0] && !isAncestor &&
!$target.closest(target).length && !$target.attr('disabled')
) {
self.hide(event);
}
});
}
```
The jQuery method jQuery.fn.closest has changed to allow jQuery objects as a param in 1.6, however in 1.4.4, it expects a string as a first argument, which is what I suspect is the issue here. If I remove the block:

```
!$target.closest(target).length &&
```

Then the error goes away.