Note that there are some explanatory texts on larger screens.

plurals
  1. PObackbone jquery debug chrome console keeps clearing the output
    text
    copied!<p>I am trying to follow a simple backbone tutorial online. The problem is when I click on "post", the tweet is posted in the log, but is cleared immediately. I am not sure why the console cleans itself right after printing out the tweets.toJSON(). I am using node and livereload2 to load the page after saving. I don't think it is livereload as the behavior is the same regardless of livereload running or not. </p> <ol> <li>Everything is wrapped in self invoking anonymous jquery function for scoping I think. So that the variables are not exposed at the window level in the DOM.</li> <li>It takes in JQuery variables as the $ sign, so that I can use it inside the function. </li> </ol> <p>Am I reading this correctly? </p> <p>Thank you for the help !.</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt;Backbone Twitter App&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;h1&gt; Backbone for twitter &lt;/h1&gt; &lt;form id="new-tweet"&gt; &lt;label&gt;Author:&lt;/label&gt; &lt;input id="author-name" name="author-name" type="text" /&gt; &lt;label&gt;Status:&lt;/label&gt; &lt;input id="status-update" name="status-update" type="text" /&gt; &lt;button&gt;Post&lt;/button&gt; &lt;/form&gt; &lt;hr/&gt; &lt;script type="text/javascript" src="underscore.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="jquery-1.9.0.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="backbone.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; (function($) { var Tweet = Backbone.Model.extend({ defaults:function(){ return { author: '', status: '' } } }); var TweetsList = Backbone.Collection.extend({ model: Tweet }); var tweets = new TweetsList(); $(document).ready(function(){ $('#new-tweet').submit(function(ev){ console.log('button pressed'); var tweet = new Tweet({author: $('#author-name').val(), status: $('#status-update').val()}); tweets.add(tweet); console.log(tweets.toJSON()); }); }); })(jQuery); &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload