Reputation: 766
I'm having a strange problem were the below line of code will not run in my JavaScript, however runs fine in the -meteor mongo terminal
resources.update({system : "booster1"},{$set:{output : 10}});
Anybody know why this wouldn't work in JavaScript, but would work in the terminal?
Here is the rest of my code
Template.FDO.events({
'change #booster1OutputSlider': function(){
var value = $('#booster1OutputSlider').val();
resources.update({system : "booster1"},{$set:{output : value}});
}
});
I have tested value to make sure it returns a usable variable, it works just as it should.
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=[Edit]=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
My resources collection is defined in another .js file in my lib folder. The code for which is below :
resources = new Meteor.Collection("Resources");
Upvotes: 2
Views: 167
Reputation: 268
And we've got your problem! Your current permissions aren't allowing you to update the document. So you can either add in some logic to find the documents ID, and select it by that ID, or you can modify your permissions. If definitely recommend the first route as opposed to the second for security purposes.
Upvotes: 1
Reputation: 268
Where/how are you defining "resources"? You might see some issues if you don't properly define, publish, and subscribe to the database. It would explain why it works in mongo, but not in your client side js.
Upvotes: 1
Reputation: 5013
Template:
<template name="FDO">
<input name="myInput" type="text" />
</template>
JS:
Template.FDO.events({
'change [name="myInput"]': function(event, template){
var value = event.target.myInput.value;
resources.update({system : "booster1"},{$set:{output : value}});
}
});
Upvotes: 0