Search code examples
javascriptformsmongodbmeteormeteor-blaze

Meteor form textbox dont clear after submit


I am running Meteor 1.4 and i try to cler the textbox with the submit button i already red every blog post about this problem but nothing is fixing it

Here is my HTML

<template name="NeuesEvent">
     <head>
    <title>Event_Planner</title>
  </head>

  <body>
    {{> NavBar}}

        <form class="add-event" >
            <input type="text" name="name" placeholder="Event Name" />
            <input type="submit" value="Bestätigen" />
        </form>

  </body>
</template>

and this is the js

Template.NeuesEvent.events({
    "submit .add-event": function(event){
        var name = event.target.name.value;

        Events.insert({
            name: name,
            createdAt: new Date()
        });

        event.target.text.value = "";

        return false;
    }
});

everything is in the right folder and works fine only the clear function doesnt work help is really appreciated Thanks ;)


Solution

  • This could possibly just be a typo:

    Try this code:

    Template.NeuesEvent.events({
        "submit .add-event": function(event){
            var name = event.target.name.value;
    
            Events.insert({
                name: name,
                createdAt: new Date()
            });
    
            event.target.name.value = "";
    
            return false;
        }
    });
    

    Changed the line event.target.text.value = ""; to event.target.name.value = "";