Method call once - yet executes twice?

Hi - i just noticed something when going one of my projects… T and (count) when logged are called twice? I figured it might have something to do with the multiple collection calls but not entirely sure.
A penny for your thoughts?

updateRoom: function(name, user){
    if (! Meteor.userId()) {
      throw new Meteor.Error("not-authorized");
    check(name, String);
    check(user, String);
    var currentUser = Meteor.users.findOne({_id: Meteor.userId()});
      if(name != null && name != undefined){
        if(user != null && user != undefined){
          var currentRoom = Rooms.findOne({roomname: name});
          var count = Rooms.find({roomname: name, participants: user}).count();
          if(count === 0){
            Rooms.update({ _id: currentRoom._id},{$push: { participants: user}});
              from: '',
              title: 'xxx',
              text: 'xx: ' + name,
              badge: 1,
              sound: "default",
              query: {userId: user}
          }else if(check === 1){
            //remove user
    }else {
        throw new Meteor.Error("not-authorized");
  "click .item": function(event, template){'updateRoom', Session.get('roomname'), this._id);

Do you have multiple .item objects? The docs state:

If a selector matches multiple elements that an event bubbles to, it will be called multiple times, for example in the case of ‘click div’ or ‘click *’.

and end up with this:

Returning false from a handler is the same as calling both stopImmediatePropagation and preventDefault on the event.

Which sounds like it may be what you want :smile:

How did i miss this? Thank you :smiley:

1 Like