INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Simulate double click on single click

Simulate double click on single click

(OP)
I am using a calendar system (pinpoint) on a website however the website users are no understanding the process of the calendar.

A user selects a date and is then presented with a list of times for that date.

The user can only select one time, however pinpoint requires them to click a start and end time. As the start and end time is the same time, they effectively have to double click their chosen time.

Despite adding descriptive text highlighting this, the users are getting muddled and fail to double click their time.

I have tried to force a double click using javascript, however it is not working

CODE --> js

<script type='text/javascript'>
$('.DOPBSPCalendar-hour').click(function() {
  $('.DOPBSPCalendar-hour').dblclick();
});
</script> 

The hours popup looks like this

CODE --> php

<div class="DOPBSPCalendar-hours" id="2_2017-01_hours" style="display: block;">
   <div class="DOPBSPCalendar-hour dopbsp-available dopbsp-selected" id="2_17:30">    
      <div class="dopbsp-bind-top">
         <div class="dopbsp-hour">&nbsp;</div>
      </div>    
      <div class="dopbsp-bind-middle dopbsp-group0">        
         <div class="dopbsp-hour">17:30 - 18:15</div>        
         <div class="dopbsp-price">&pound;5</div>        
         <div class="dopbsp-available">18 available</div>        
         <div class="dopbsp-info" id="2_17:30_info"></div>    
      </div>    
      <div class="dopbsp-bind-bottom">
         <div class="dopbsp-hour">&nbsp;</div>
      </div>
   </div>
</div> 

And here is a video showing the double click requirement

https://www.dropbox.com/s/sntf1882kmd1rhv/doublecl...

Have I missed something?

Thanks

RE: Simulate double click on single click

Hi

According to my experience, just calling the .dblclick() method only forwards the calls to an event handler you assigned earlier.

To properly simulate an event you have to instantiate it and dispatch it :

CODE --> JavaScript

document.getElementsByClassName('DOPBSPCalendar-hour')[0].dispatchEvent(new MouseEvent('dblclick', {'bubbles': true})) 

No idea how portable is. ( Only tried on FireFox. ) No idea how to achieve the same with jQuery. With the bubbles option also works if the event listener is bound to a parent of the dispatcher element.

Feherke.
feherke.ga

RE: Simulate double click on single click

(OP)
Thanks feherke, getting closer, I found this fiddle doing something similar by instantiating and dispatching it.

http://jsfiddle.net/7s45s/

Can't quite seem to get it to double click itself

RE: Simulate double click on single click

Hi

Yepp, essentially the same. Mozilla Developer Network calls it "the old-fashioned way".

Sorry, at this point I can not imagine what exactly is in the code. For further hints on debugging this I would need to see that code running. sad

Feherke.
feherke.ga

RE: Simulate double click on single click

Hi

But I see no code there that would handle a dblclick event. surprise

Anyway, I would say it is just matter of configuration. Somewhere in the middle of HTML there is the JavaScript call that initializes the calendar :

CODE --> ( fragment, lines 159..163 )

159 <script type="text/JavaScript">
160     jQuery(document).ready(function(){
161         jQuery("#DOPBSPCalendar2").DOPBSPCalendar({/*...*/});
162     });
163 </script> 
In that huge line there is a fragment where you can change multipleSelect to false :

CODE --> ( fragment, line 161 )

// before
"hours":{"data":{"addLastHourToTotalPrice":false,"ampm":false,"definitions":[{"value":"00:00"}],"enabled":true,"info":true,"interval":true,"multipleSelect":true},"text":[]}
// after
"hours":{"data":{"addLastHourToTotalPrice":false,"ampm":false,"definitions":[{"value":"00:00"}],"enabled":true,"info":true,"interval":true,"multipleSelect":false},"text":[]} 
That seems to instruct the script to do what you want.

Feherke.
feherke.ga

RE: Simulate double click on single click

(OP)
Aha, initially I contacted the plugin authors who said that due to the way the plugin is coded it is not possible to facilitate one click without much modification. Shouldn't have taken their word for it. Thanks Feherke, with your help I managed to find the file and line deep in their file structure that added this setting.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close