流星调用/方法只触发一次?

时间:2017-07-07 11:16:57

标签: javascript meteor meteor-blaze

这里是另一个noob流星问题,我在服务器端调用此方法来插入或更新我的收藏

'insertPipeLine': function (obj,sourceConnectionId,targetIdConnectionId) {
        let insertDATA = Async.runSync(function (done) {
            let dataFields = [];
            for (let i = 0; i < obj.length; i++) {
                var  targPoints = [], sourPoints = [];
               for(w = 0; w < obj[i].points.length; w++){
                    if(obj[i].points[w].type == "Rectangle"){
                        targPoints.push(obj[i].points[w].point)
                    }else if(obj[i].points[w].type == "Dot"){
                        sourPoints.push(obj[i].points[w].point)
                    }
                };

                dataFields[i] = {
                    "currID": obj[i].currID,
                    "html": obj[i].html,
                    "left": obj[i].left,
                    "top": obj[i].top,
                    "width": obj[i].width,
                    "height": obj[i].height,
                    "targetPoints": targPoints,
                    "sourcePoints": sourPoints,
                };
            }
            console.log(sourceConnectionId,targetIdConnectionId)
            let checkData = PipeLine.findOne({userId: Meteor.userId()});
            if (checkData) {
                PipeLine.update(checkData._id, {
                    $set:{
                        data: dataFields,
                        sourceConnections:sourceConnectionId,
                        targetConnections:targetIdConnectionId
                    }
                }), function (err, response) {
                    if (err) {
                        return err
                    } else {
                        return response
                    }
                }
            }
            else {
                PipeLine.insert({
                    userId: Meteor.userId(),
                    data: dataFields,
                    sourceConnections:sourceConnectionId,
                    targetConnections:targetIdConnectionId
                }), function (err, response) {
                    if (err) {
                        return err
                    } else {
                        return response
                    }
                }
            }


        });

        return insertDATA;
    }

然后我有一个模板事件onclick从“表单”读取数据并将其发送到方法以插入或更新集合

   "click #savePipeLine": function(j, blaze, a, b,sourceConnectionId,targetIdConnectionId){
    j.preventDefault();
    var obj = [];
    console.log("trigger");
    console.log(sourceConnectionId,targetIdConnectionId)
    $('.window').each(function(e,l) {
        var currID = $(this).attr('id'),
            html   = $(this).html(),
            left   = $(this).css('left'),
            top    = $(this).css('top'),
            width  = $(this).css('width'),
            height = $(this).css('height');
           if(currID == b[e].el){
               var points = b[e].points;
           }
        obj.push({"currID":currID, "html":html, "left":left,"top": top,"width": width,"height": height, "points": points });
    });
    Meteor.call('insertPipeLine', obj, sourceConnectionId, targetIdConnectionId);
}

一切正常但它只触发一次,我有listenEvent会触发点击“更改”内容,它会触发但是一旦它进入Meteor.Call它只触发第一次,第二次和跟随上升时间触发事件点击并且所有数据都存在,但Meteor.Call只是没有做任何事情,没有错误没有输出

0 个答案:

没有答案