Reputation: 127
normally my inserts are working fine but today i could crush Meteor ;)
I already removed insecure and Autopublish and checked the code hundred times but the insert gets not executed.
My hmtl:
<template name="neuesGebietErstellen">
<div id="viewport">
<form class="add-Gebiet">
<input type="text" name="Gebietsname" placeholder="Gebietsname"><br>
<input type="text" name="Gebietsnummer" placeholder="Gebietsnummer"><br>
<input type="text" name="Ort" placeholder="Stadt / Ort"><br>
<input type="submit" value="Gebiet hinzufügen">
</form>
</div>
</template>
my js:
import { Meteor } from 'meteor/meteor'
Template.neuesGebietErstellen.onCreated(function () {
this.subscribe('gebiete');
});
Template.neuesGebietErstellen.events({
"submit .add-Gebiet": function (event) {
var Gebietsname = event.target.Gebietsname.value;
var Gebietsnummer = event.target.Gebietsnummer.value;
var Ort = event.target.Ort.value;
Meteor.call('neuesGebiet', Gebietsname, Gebietsnummer, Ort)
console.log("hat geklappt");
return false;
}
});
My method file in the server folder:
Meteor.methods({
neuesGebiet(Gebietsname, Gebietsnummer, Ort) {
console.log("Methode wurde aufgerufen");
Gebiete.insert({
Gebietsname: Gebietsname,
Gebietsnummer: Gebietsnummer,
Ort: Ort
});
}
});
The strange part is i get both console logs so my event is executed and the method is called too but with meteor toys i check my collection and there nothing is getting inserted. So please help me ;)
Upvotes: 0
Views: 60
Reputation: 20226
Usually the problem is that the record is being inserted but is not being published back out to the client so the client never sees it.
autopublish
package? If so...Gebiete
collection from the server andUpvotes: 1
Reputation: 51
Make sure you have the collection-object Gebiete declared/defined as well like this.
let Gebiete = new Meteor.Collection('gebiete');
Upvotes: 0