title: onsubmit breaks Jade view
body: <p>I have a form page that takes some inputs, stores the data in mongo and returns the data to the view underneath the form. However, when a user submits new data on the form, the jade view crashes and displays the following error:</p>
  
  <pre><code>TypeError: /Users/rhysedwards/Downloads/insightful/food/views/index.jade:29
      27|         label
      28|           input.btn.btn-default(name='submit', type='submit', onsubmit="this.submit(); this.reset(); return false;")
    &gt; 29|       each Entry, i in entries
      30|         div.title= Entry.title
      31|         div.url= Entry.url
      32|         div.selectedDate= Entry.selectedDate
  
  Cannot read property 'length' of undefined
  </code></pre>
  
  <p>The expected behaviour is that when a user submits new data through the form, it displays underneath the form. Why does <code>Entry</code> become undefined onsubmit but the data still displays prior to a submit?</p>
  
  <p>Router</p>
  
  <pre><code>router.get('/', function(req, res, next){
    Entry.find({}, function (err, entries) {
      res.render('index', {
        "entries": entries
      });
    });
  });
  </code></pre>
  
  <p>Jade</p>
  
  <pre><code>block content
    .container
      h1 London Plans
      form(method='post' action='post', class='plans', id='plans')
        .form-group
          label Do you have a link?
          input.form-control(name='search', id='search' type='url', required='required')
          h2#title
        .form-group
          label What looks cool?
          input.form-control(name='title', type='text', required='required' class='title')
        .form-group
          label When is it?
          label
            input(type='checkbox' name='week' value='week')
            span This week
          label
            input(type='checkbox' name='month' value='month')
            span This Month
          label
            input(type='checkbox' id='date')
            span Date
          label
            input(type='textbox' class='datepicker' name='date' value='')
          label
            input.btn.btn-default(name='submit', type='submit', onsubmit="this.submit(); this.reset(); return false;")
        each Entry, i in entries
          div.title= Entry.title
          div.url= Entry.url
          div.selectedDate= Entry.selectedDate
  </code></pre>
  
  <p>Post function</p>
  
  <pre><code>router.post('/post', function(req, res, next) {
    var url = req.body.search;
    var title = req.body.title;
    var week = req.body.week;
    var month = req.body.month;
    var date = req.body.date;
  
    console.log(url + ' ' + title + ' ' + week + ' ' + month + ' ' + date);
  
    //FIND WHICH DATE WAS SELECTED BY USER AND ASSIGN THAT TO selectedDate
    if (typeof week != 'undefined' ){
      var selectedDate = 'week';
    } else if (typeof month != 'undefined') {
      var selectedDate = 'month';
    } else {
      var selectedDate = date;
    };
  
    //CREATE NEW OBJECT
    var data = new Entry ({
      url: url,
      title: title,
      selectedDate: selectedDate
    })
  
    //STORE NEW OBJECT TO THE DB
    Entry.createEntry(data, function(err, entry){
      if (err) throw err;
      console.log(entry);
    })
  
    //RENDER THE HOMEPAGE TO CLEAR THE FORM
    res.render('index');
    return false;
  });
  </code></pre>