Mic starts working but doesnt add to list item, also manual adding of list item using the form adds it for a second and then drops it


#1

Hello,

My microphone is working with Annyang but isnt adding a list item. Additionally when i use the form and submit a manual typed list item it sticks for a split second and disappears. Can someone take a look at my code?

jQuery -

    var template = function(text) {
      return '<p><input type="checkbox"><i class="glyphicon glyphicon-star"></i><span>' + text + '</span><i class="glyphicon glyphicon-remove"></i></p>';
    };

var main = function() {
  $('form').submit(function() {
     var text = $('#todo').val();
    var html = template(text);
    $('.list').append(html);
    
  });
         var commands = {
           'add *item': add 
         };
     var add = function(item) {
       var html = template(item);
       $('.list').append(html);
     };
    
    annyang.addCommands(commands);
  annyang.start();
      
  };

$(document).ready(main);


#2

Hey dude,

Try to use If statement

if (annyang) {
var commands = you code... and the end don't forget to close if statement