gpt4 book ai didi

javascript - 双击时间轴时如何删除添加项目事件?

转载 作者:行者123 更新时间:2023-12-01 01:22:32 25 4
gpt4 key购买 nike

我在使用 vis.js 的时间轴应用程序时遇到问题。

当我双击时间轴时,我需要删除添加项目事件。我已经用这段代码尝试过,但没有成功。有人可以帮助我吗?

我已经使用我使用的代码编辑了问题。

    <!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<div id="visualization"></div>


<link href="https://cdnjs.cloudflare.com/ajax/libs/vis/4.17.0/vis.min.css" rel="stylesheet" type="text/css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/vis/4.17.0/vis.min.js"></script>

<script type="text/javascript">
// DOM element where the Timeline will be attached
var container = document.getElementById('visualization');

// Create a DataSet (allows two way data-binding)
var items = new vis.DataSet([
{id: 1, content: 'item 1', start: '2014-04-20'},
{id: 2, content: 'item 2', start: '2014-04-14'},
{id: 3, content: 'item 3', start: '2014-04-18'},
{id: 4, content: 'item 4', start: '2014-04-16', end: '2014-04-19'},
{id: 5, content: 'item 5', start: '2014-04-25'},
{id: 6, content: 'item 6', start: '2014-04-27', type: 'point'}
]);

// Configuration for the Timeline
var options = {
clickToUse: true,
editable:true,
doubleClickMode:false
};

// Create a Timeline
var timeline = new vis.Timeline(container, items, options);
timeline.on('click', function (properties) {
console.log("Click event fired");
});

timeline.on('doubleClick', function (properties) {
console.log("Double click event fired");
});

</script>

</body>
</html>

最佳答案

我已经用这段代码完成了:

<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<div id="visualization"></div>


<link href="https://cdnjs.cloudflare.com/ajax/libs/vis/4.17.0/vis.min.css" rel="stylesheet" type="text/css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/vis/4.17.0/vis.min.js"></script>

<script type="text/javascript">
// DOM element where the Timeline will be attached
var container = document.getElementById('visualization');

// Create a DataSet (allows two way data-binding)
var items = new vis.DataSet([
{id: 1, content: 'item 1', start: '2014-04-20'},
{id: 2, content: 'item 2', start: '2014-04-14'},
{id: 3, content: 'item 3', start: '2014-04-18'},
{id: 4, content: 'item 4', start: '2014-04-16', end: '2014-04-19'},
{id: 5, content: 'item 5', start: '2014-04-25'},
{id: 6, content: 'item 6', start: '2014-04-27', type: 'point'}
]);

// Configuration for the Timeline
var options = {
clickToUse: true,
editable:{
add: false,
remove: true
}

};

// Create a Timeline
var timeline = new vis.Timeline(container, items, options);
timeline.on('click', function (properties) {
console.log("Click event fired");
});

timeline.on('doubleClick', function (properties) {
console.log("Double click event fired");
});

</script>

</body>
</html>

关于javascript - 双击时间轴时如何删除添加项目事件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54110417/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com