Created
August 10, 2013 09:23
-
-
Save rudovjan/6199750 to your computer and use it in GitHub Desktop.
Check method Template.room.events
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Rooms = new Meteor.Collection('rooms'); | |
if (Meteor.isServer && Rooms.find().count() == 0) { | |
var roomsA = [ | |
{name: 'Meteor Talk', members: 3, last_activity: '1 minute ago', id: 0, | |
messages: [ | |
{author: 'Tom', text: 'Hi there Sacha!'}, | |
{author: 'Sacha', text: 'Hey Tom, how are you?'}, | |
{author: 'Tom', text: 'Good thanks!'}, | |
]}, | |
{name: 'Meteor Development', members: 2, last_activity: '5 minutes ago', id: 1}, | |
{name: 'Meteor Core', members: 0, last_activity: '3 days ago', id: 2} | |
]; | |
for (var i = 0; i < roomsA.length; i++) { | |
Rooms.insert(roomsA[i]); | |
}; | |
} | |
if (Meteor.isClient) { | |
Meteor.Router.add({ | |
'/': 'home', | |
'add': function () { return 'test'}, | |
'/rooms/:id': function(id) { //THIS IS THE ROUTER CALL TO THE ROOMS LINKS | |
Session.set('currentRoomId', id); | |
return 'chatRoom' | |
} | |
}); | |
Template.room.rooms = function () { | |
return Rooms.find(); | |
}; | |
Template.chatRoom.id = function() { | |
var id = Session.get('currentRoomId', id); | |
return id; | |
}; | |
Template.room.events({ | |
'click .goToRoom': function(e, t){ | |
console.log("You clicked"); | |
console.log(this); | |
Meteor.Router.to('/rooms/' + this.id); | |
} | |
}) | |
console.log(Rooms.find().fetch()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment