Dblclick event on a list item. always go to top of page from single click ... how disable scroll on click so can dblclick

dblclick event on a list item (list dynamically created)… always go to top of page from single click… can not dblclick… In other words for items scrolled list below I auto get scroll to top…? how disable scroll on click so can dblclick…???
$(‘a’, list).on(“dblclick”, function(e) { // eventSupportedbyDevice
$(‘#dataDiv’).hide();
$(“#carDetails”).show();
$(“.panel-title”).text("Car Details for CarID: " + $(this).attr(‘data-carid’));
fetchDataForCarID($(this).attr(‘data-carid’));
});

I think is the way I bind list items to dblclick…
note:
var list = $(“#dataDiv”);

EXIST ANY OTHER WAY BIND A BOOTSTRAP LIST ITEMS TO DBLCLICK…?

may be your list item contains a link like that: <a href="#">…</a>, which would indeed go to the top, because that’s what it’s supposed to do.

a href=“#” what have to be ? if a binded like above???

simply don’t use a href if you don’t plan on linking to something.

If I understood you correctly, why don’t you simply remove the bit that does the scrolling?

If you still want the scrolling for other elements, make the according selector more specific, so that the click event doesn’t get triggered for elements within the list. You can do this by either giving those “scroll-links” a specific class (say, .scroll), or the other way round by excluding links within that #dataDiv, like

$('a.scroll').click( //scroll stuff

or

$('a:not(#dataDiv a)').click( //scroll stuff

respectively. Alternatively, you can .unbind() the click event like

$('a', list).unbind('click');

But I’d strongly suggest not to bind the event in the first place if the scroll behaviour is not desired anyway.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.