What event to use to call taphold?
I'm technically using a separate script for taphold instead of jQuery Mobile, but when I tested with JQM I had the same problem.
I have a page (infinite scroll) with potentially 2000+ elements. I want the user to be able to taphold any one of these elements to run an Ajax script.
What is the proper event to use in order to trigger the taphold?
Here is my code:
- function holdClick(id, username) {
- $('#list_' + id).on('taphold', function(e) {
- alert('worked');
- // I tried removing the following 2 lines, but it had no impact on the problem
- e.stopImmediatePropagation();
- return false;
- });
- }
- // CSS
- [data-listid] {
- height: 110px;
- padding: 10px;
- margin-bottom: 20px;
- border: 1px solid #C7D9E3;
- border-radius: 4px;
- -webkit-touch-callout: none;
- -webkit-user-select: none;
- -khtml-user-select: none;
- -moz-user-select: none;
- -ms-user-select: none;
- user-select: none;
- -webkit-tap-highlight-color: rgba(0,0,0,0);
- }
- [data-listid]:hover { background: #F5F7F9 }
- // Example of the HTML
- <div id="list_12345" data-listid="12345" data-user="csdude55"
- itemscope itemtype="http://schema.org/Product"
- onClick="holdClick('12345', 'csdude55')">
- Blah blah blah
- </div>
The problem I'm having is that it doesn't work when I hold the first time, but after I let off and taphold several times it will finally work. I can't figure out if the problem is with the onClick (I also tried using onMouseDown), the script I'm using, the :hover in CSS, or the JQM script.