craigsworks.com - Support Forum

Full Version: How to disable qTip upon AJAX failure?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have the following code but it doesn't seem to work properly.

JS Code
$(this).qtip({
	overwrite: false,
	content: {
		text: 'Loading...',
		title: 'Who liked this',
		ajax: {
			loading: false,
			url: '/api_proxy/comments/'+cid+'/likes/',
			type: 'GET',
			dataType: 'json',
			error: function() {
				this.hide();
				this.disable(true);
			},
			statusCode: {
				204: function() {
					this.hide();
					this.disable(true);
				}
			},
			success: function(json_reply, status) {
				var linked_usernames = new Array();
				for (var i=0; i<json_reply.length; i++) {
					var avatarURL = json_reply[i].avatar_img.replace('/m/', '/m/xs/');
					var link = '<div><a href="'+json_reply[i].url+'"><img src="'+avatarURL+'" style="max-width: 12px; max-height: 12px;" /> <span>'+json_reply[i].username+'</span></a></div>';
					linked_usernames.push(link);
				}
				this.set('content.text', linked_usernames.join(''));
			}
		}
	},
	..... the rest of settings .....
What do you mean by "not work properly"?
The code above should disable the tooltip if there's no results to be shown (statusCode: 204).
However, the following happens when seen in the browser:
first mouseover, no tooltip shown
mouseout then mouseover again, a tooltip like below is displayed.
[Image: UpnqS.png]
Can you setup a test case for this please? http://jsfiddle.net/fDavN/
Reference URL's