Im very new to Meteor, so please let me know if im doing something wrong, or if’s possible for me to improve on my code .
Im trying to insert a simple name value in my database. However the value is being returned as ‘null’ in my database, so maybe im not retrieving my value properly…
Can anyone point me in the right direction on this one?
Also is there a better meteor way of retrieving my value when the value is not coming from an input field?
My client side script:
'click .show': function(event) {
event.preventDefault();
var currentUserId = Meteor.userId();
var element = event.target;
var showName = $(element).text();
Meteor.call('addShow');
console.log(showName);
}
Im probably tackling this the wrong way, but I want to have a collection of shows that the user can select from (which is the ones im fetching from themoviedb.org api). But I also want to enable the user to actually add shows to their list, and the only way I could see that possible was to make a new collection and store the usersShows there.
Here is the entire client code:
Shows = new Meteor.Collection('shows');
Session.setDefault('searching', false);
Tracker.autorun(function() {
if (Session.get('query')) {
var searchHandle = Meteor.subscribe('showsSearch', Session.get('query'));
Session.set('searching', ! searchHandle.ready());
}
});
Template.body.events({
'submit form': function(event, template) {
event.preventDefault();
var query = template.$('input[type=text]').val();
if (query)
Session.set('query', query);
},
'click .show': function(event) {
var currentUserId = Meteor.userId();
var element = event.target;
var showName = $(element).text();
Meteor.call('addShow');
console.log(showName);
}
});