How to raise a click event for a vis.js Timeline (to get the result of a click when the clickToUse option is...
up vote
0
down vote
favorite
I have multiple timelines in a project that uses vis.js, generated by a PHP code.
There is an option for timelines, called clickToUse, if which is set to True, it causes the specific timeline to get selected when the user clicks on the timeline, causing a shadowed outline appearing around it.
I'm using an additional div header with title and various information regarding to the timeline below it.
I would like to have the timeline selected from code (causing to have the shadowed outline) when I click on the header div, so something that happens when the user clicks on the timeline.
How can this be done? Any help would be appreciated.
events click timeline vis.js raise
add a comment |
up vote
0
down vote
favorite
I have multiple timelines in a project that uses vis.js, generated by a PHP code.
There is an option for timelines, called clickToUse, if which is set to True, it causes the specific timeline to get selected when the user clicks on the timeline, causing a shadowed outline appearing around it.
I'm using an additional div header with title and various information regarding to the timeline below it.
I would like to have the timeline selected from code (causing to have the shadowed outline) when I click on the header div, so something that happens when the user clicks on the timeline.
How can this be done? Any help would be appreciated.
events click timeline vis.js raise
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have multiple timelines in a project that uses vis.js, generated by a PHP code.
There is an option for timelines, called clickToUse, if which is set to True, it causes the specific timeline to get selected when the user clicks on the timeline, causing a shadowed outline appearing around it.
I'm using an additional div header with title and various information regarding to the timeline below it.
I would like to have the timeline selected from code (causing to have the shadowed outline) when I click on the header div, so something that happens when the user clicks on the timeline.
How can this be done? Any help would be appreciated.
events click timeline vis.js raise
I have multiple timelines in a project that uses vis.js, generated by a PHP code.
There is an option for timelines, called clickToUse, if which is set to True, it causes the specific timeline to get selected when the user clicks on the timeline, causing a shadowed outline appearing around it.
I'm using an additional div header with title and various information regarding to the timeline below it.
I would like to have the timeline selected from code (causing to have the shadowed outline) when I click on the header div, so something that happens when the user clicks on the timeline.
How can this be done? Any help would be appreciated.
events click timeline vis.js raise
events click timeline vis.js raise
asked Nov 11 at 19:21
Gergő Gyula
12
12
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
Finally I've figured it out, this is my solution. First of all, I had to use stopPropagation, because basically vis.js deactivates a timeline when the user clicks anywhere else but on the timeline. So clicking on the header div would deactivate the timeline right after we activate it.
Looking in the vis.js code, I found that it uses an Activator object to handle activation/deactivation when clickToUse is set to true. If it is set to false, the Activator is not propagated in the Timeline object. The Activator object has an "activate" and "deactivate" function (and some others) that can be called (it's not written in the vis.js documentation).
So, I'm using the following code and it works:
document.getElementById('headerdiv').addEventListener('click', function() {
event.stopPropagation();
timeline.activator.activate();
});
If you call .activate(), it also deactivates the other timelines (if you have multiple), so no need to call any other functions, because everything is written in the activate() function: the css change, the emitters, the key binding.
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
Finally I've figured it out, this is my solution. First of all, I had to use stopPropagation, because basically vis.js deactivates a timeline when the user clicks anywhere else but on the timeline. So clicking on the header div would deactivate the timeline right after we activate it.
Looking in the vis.js code, I found that it uses an Activator object to handle activation/deactivation when clickToUse is set to true. If it is set to false, the Activator is not propagated in the Timeline object. The Activator object has an "activate" and "deactivate" function (and some others) that can be called (it's not written in the vis.js documentation).
So, I'm using the following code and it works:
document.getElementById('headerdiv').addEventListener('click', function() {
event.stopPropagation();
timeline.activator.activate();
});
If you call .activate(), it also deactivates the other timelines (if you have multiple), so no need to call any other functions, because everything is written in the activate() function: the css change, the emitters, the key binding.
add a comment |
up vote
0
down vote
Finally I've figured it out, this is my solution. First of all, I had to use stopPropagation, because basically vis.js deactivates a timeline when the user clicks anywhere else but on the timeline. So clicking on the header div would deactivate the timeline right after we activate it.
Looking in the vis.js code, I found that it uses an Activator object to handle activation/deactivation when clickToUse is set to true. If it is set to false, the Activator is not propagated in the Timeline object. The Activator object has an "activate" and "deactivate" function (and some others) that can be called (it's not written in the vis.js documentation).
So, I'm using the following code and it works:
document.getElementById('headerdiv').addEventListener('click', function() {
event.stopPropagation();
timeline.activator.activate();
});
If you call .activate(), it also deactivates the other timelines (if you have multiple), so no need to call any other functions, because everything is written in the activate() function: the css change, the emitters, the key binding.
add a comment |
up vote
0
down vote
up vote
0
down vote
Finally I've figured it out, this is my solution. First of all, I had to use stopPropagation, because basically vis.js deactivates a timeline when the user clicks anywhere else but on the timeline. So clicking on the header div would deactivate the timeline right after we activate it.
Looking in the vis.js code, I found that it uses an Activator object to handle activation/deactivation when clickToUse is set to true. If it is set to false, the Activator is not propagated in the Timeline object. The Activator object has an "activate" and "deactivate" function (and some others) that can be called (it's not written in the vis.js documentation).
So, I'm using the following code and it works:
document.getElementById('headerdiv').addEventListener('click', function() {
event.stopPropagation();
timeline.activator.activate();
});
If you call .activate(), it also deactivates the other timelines (if you have multiple), so no need to call any other functions, because everything is written in the activate() function: the css change, the emitters, the key binding.
Finally I've figured it out, this is my solution. First of all, I had to use stopPropagation, because basically vis.js deactivates a timeline when the user clicks anywhere else but on the timeline. So clicking on the header div would deactivate the timeline right after we activate it.
Looking in the vis.js code, I found that it uses an Activator object to handle activation/deactivation when clickToUse is set to true. If it is set to false, the Activator is not propagated in the Timeline object. The Activator object has an "activate" and "deactivate" function (and some others) that can be called (it's not written in the vis.js documentation).
So, I'm using the following code and it works:
document.getElementById('headerdiv').addEventListener('click', function() {
event.stopPropagation();
timeline.activator.activate();
});
If you call .activate(), it also deactivates the other timelines (if you have multiple), so no need to call any other functions, because everything is written in the activate() function: the css change, the emitters, the key binding.
answered Nov 15 at 19:25
Gergő Gyula
12
12
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53252310%2fhow-to-raise-a-click-event-for-a-vis-js-timeline-to-get-the-result-of-a-click-w%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown