Jump to content

Double click instead of single click


bytesize

Recommended Posts

If jquery 1.3 is used with this code a single click works, which is what I want, but if jquery 1.4 or higher is used a double click is required.

Can anyone tell me what is causing the double click?


<head>
<style type="text/css">
.interactionLinksDiv a {
	font-size: 12px;
	font-family: Geneva, sans-serif;
	font-weight: normal;
}
.interactionLinksDiv a:hover {
	font-size:12px;
	text-decoration: underline;
}
.interactContainers {
	display:none;
	margin-top: 4px;
}
</style>
<script type="text/javascript">
	function toggleInteractContainers(x) {
		if ($('#'+x).is(":hidden")) {
			$('#'+x).slideDown(200);
		} else {
			$('#'+x).hide();
		}
		$('.interactContainers').hide();
	}
</script>
</head>
<body>
<?php
	$interactionBox = '<div class="interactionLinksDiv">
	 <a href="#" onclick="return false" onmousedown="toggleInteractContainers(\'add_friend\');">Add <b>Joey</b> to Friends</a>
	</div>';
	echo $interactionBox;
	?>
<div class="interactContainers" id="add_friend">
		Friend <b>Joey</b>? <a href="#" onclick="return false" onmousedown="toggleInteractContainers('add_friend');" title="Close">Later</a>
	</div>
</body>
</html>
Link to comment
Share on other sites

Try using something like this...

 

$.fn.req = $.fn.jquery.indexOf("1.3.") > -1 ? $.fn.click : ($fn.jquery.substr($.fn.jquery.indexOf("1.4."),$.fn.jquery.lastIndexOf(".")) >= "1.4" ? $.fn.dblclick : $.fn.click);
If the jQuery version is 1.3 (or any version of 1.3), the $.fn.req property will be the normal click method of the jQuery object, otherwise, if the version is 1.4 or higher, it will be the dblclick function.

So, to write code with the .req property, you'd do something like this.

 

$(function(){
$('#clicked_element').req(function(e){
alert(e + " was fired.");
});
});
By the way, $.fn is the jQuery prototype object.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.