<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Anthony King on Medium]]></title>
        <description><![CDATA[Stories by Anthony King on Medium]]></description>
        <link>https://medium.com/@anthonyking_72578?source=rss-174236d1a402------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*FIIdpcL0qy3_pAs5.</url>
            <title>Stories by Anthony King on Medium</title>
            <link>https://medium.com/@anthonyking_72578?source=rss-174236d1a402------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 08:48:27 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@anthonyking_72578/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[MVC in 15: Backbone.js]]></title>
            <link>https://medium.com/summercode-js/mvc-in-15-backbone-js-c2a907344a59?source=rss-174236d1a402------2</link>
            <guid isPermaLink="false">https://medium.com/p/c2a907344a59</guid>
            <category><![CDATA[hack-reactor]]></category>
            <category><![CDATA[backbonejs]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Anthony King]]></dc:creator>
            <pubDate>Sat, 07 Jul 2018 13:33:10 GMT</pubDate>
            <atom:updated>2018-07-07T13:35:19.352Z</atom:updated>
            <content:encoded><![CDATA[<p>In week three of Hack Reactor’s immersive we implement the same video player app with three different MVC frameworks. With little previous front-end experience it was a whirlwind week for me. By the time I started to feel comfortable with one MVC we moved to the next, and one of the suggestions staff gave me to reinforce the core concepts of each framework was to distill the main concepts into fifteen lines of code.</p><p>So here’s as much backbone as I could fit into fifteen lines. If you’d like an easy way to try some backbone code head over to <a href="http://backbonejs.org/">backbone.js</a>, open up your chrome dev tools, and run the below in a snippet.</p><pre>1  $(&quot;body&quot;).empty();<br>2  var ToDo = Backbone.Model.extend({<br>3    initialize: function(task) { this.set({ task: task }); }<br>4  });<br>5  var ToDoView = Backbone.View.extend({<br>6    events: { click: &quot;deleteTask&quot; },<br>7    deleteTask: function() { this.$el.hide(); },<br>8    render: function() {<br>9     var html = [&quot;&lt;li&gt;&quot;, this.model.get(&quot;task&quot;), &quot;&lt;/li&gt;&quot;].join(&quot;&quot;);<br>10    return this.$el.html(html);<br>11   }<br>12 });<br>13 var todo1 = new ToDo(&quot;review React next&quot;);<br>14 var todoView = new ToDoView({ model: todo1 });<br>15 $(&quot;body&quot;).append(todoView.render());</pre><p>All of the first and most of the last line are jQuery, which is included in backbone. The first clears the webpage and the last appends a rendered backbone View instance to the body of the page.</p><p>I’ve cheated a bit by compressing some code that should be on multiple lines in order to fit examples of a backbone Model, View, and an event in the fifteen lines. The backbone Model allows us to create instances of a class as needed, and the associated view contains an html template and an event handler. Lines 13 and 14 create and associate our Model and View instances, with the Model instance passed in as the value of the view’s ‘model’ property. Our simple event handler hides the to-do task when clicked. $el on line 7 is a free jQuery object provided by every backbone view that refers to the view itself. $elis cached so that we’re not performing a jQuery lookup each time we want to use a jQuery method on it. Both models and views can be grouped into model and view collections, which I didn’t have room to demonstrate here. Collecting models allows us perform tasks on similarly structured objects in our apps, while a collection of views would include an html template for presenting the associated views within a container.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c2a907344a59" width="1" height="1" alt=""><hr><p><a href="https://medium.com/summercode-js/mvc-in-15-backbone-js-c2a907344a59">MVC in 15: Backbone.js</a> was originally published in <a href="https://medium.com/summercode-js">summerCode.js</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>