0

我正在尝试在我的时间线上获取 onMoving 的回调,但不断收到错误消息:

“(错误):选项 onMoving 必须是函数 onMoving(item, callback)”

这就是我想要做的

options.onMoving = function (item, callback) {console.log('onMoving')};

对于像 snap 这样的其他事情,这没有任何问题

options.snap = function(date, scale, step) {
    var hour = snapTimeMinutes * 60 * 1000;
    return Math.round(date / hour) * hour
}

我该如何解决这个错误?

我没有在 options 对象上执行其他事件,而是在以下代码之类的项目上执行此操作,但这似乎不适用于onUpdating.

itemsJS.on('update', function (event, properties) {
});

我无法直接声明选项 JSON,因为我将代码包装在 GWT 中。而且我不能将函数放在对象中......

附加信息:

我想要实现的是使用onMoving选项的回调。就像在这个 JS 示例中一样:查看源代码:http: //visjs.org/examples/timeline/editing/editingItemsCallbacks.html

在我的包装器中,我创建了一个 Java Options 对象,例如。

public class Options
{
   private boolean moveable = true;
   private boolean showCurrentTime = false;
   ....
}

然后我在 java 中创建这样一个 Options 对象并设置正确的参数。

然后在我的包装器中,我使用 GWTJackson 将 Options 对象转换为 JSON 字符串。

最后在 JSNI 方法中,我执行以下操作:

var options = JSON.parse(optionsJson);

if (snapTimeMinutes != 0)
     options.snap = function(date, scale, step) {var hour = snapTimeMinutes * 60 * 1000; return Math.round(date / hour) * hour} //I can still add parameters in the jsni method to the JS Options object, but if I try this with onMoving I get the error specified in the beginning of this post

timeline = new $wnd.vis.Timeline(container, itemsJS, groups, options);

这对于布尔、字符串、整数、浮点数等普通字段都没有问题……但我不知道如何添加那个onMoving东西,因为它是一个函数。

4

1 回答 1

0

尝试添加

selectable: true,  
editable: {
    updateTime: true,
},

到你的选择。

文档说onMoving
当两个选项 selectable 和 editable.updateTime 或 editable.updateGroup 都设置为 true 时才适用

于 2018-06-05T09:32:32.597 回答