Insert failed method is not found

时间:2015-07-29 00:46:55

标签: jquery html meteor

Jquery

if(graphPoints[i] == highlightPoint){
            var point2 = CGPoint(x:columnXPoint(i), y:columnYPoint(graphPoints[i]))
            point2.x -= 8.0/2
            point2.y -= 8.0/2
            let circle2 = UIBezierPath(ovalInRect:
                CGRect(origin: point2,
                    size: CGSize(width: 8.0, height: 8.0)))
            highlightColor.setFill()
            highlightColor.setStroke()
            circle2.fill()
            let circle = UIBezierPath(ovalInRect:
                CGRect(origin: point,
                    size: CGSize(width: 5.0, height: 5.0)))
            UIColor.whiteColor().setFill()
            UIColor.whiteColor().setStroke()

            circle.fill()
            var pointLabel : UILabel = UILabel()
            pointLabel.text = "Point = \(graphPoints[i])"
            pointLabel.frame = CGRectMake(point2.x, point2.y, 100, 50)
            self.addSubview(pointLabel)
        } else {
            let circle = UIBezierPath(ovalInRect:
                CGRect(origin: point,
                    size: CGSize(width: 5.0, height: 5.0)))
            UIColor.whiteColor().setFill()
            UIColor.whiteColor().setStroke()
            circle.fill()

        }

Server side

DiceResults = new Mongo.Collection("dice");

if (Meteor.isClient) {
    Meteor.subscribe("dice");
    Template.boardGame.events({

        'click #roll' : function() {
            var dice = $('.die').map(function () {
            return $(this).attr('src')
            }).get();
            for(var z =0; z<dice.length; z++){
                DiceResults.insert({
                    sides:dice[z]
                });

            }

        }
    });
}

On the client side it map the variable dice to 6 images with the class die. From there I would use a loop to insert everything from the array dice to DiceResults. Yet I get insert failed method is not. Help would be appreciated thank you

1 个答案:

答案 0 :(得分:1)

你需要确定这一行:

{{1}}

出现在公共代码中(在服务器和客户端上运行的代码)。

为此,请确保它在客户端/或服务器/目录之外的文件中运行。