Organizing view files for Event reg front end.
authorSteve Sutton <steve@gaslightmedia.com>
Wed, 23 Aug 2017 20:07:57 +0000 (16:07 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Wed, 23 Aug 2017 20:07:57 +0000 (16:07 -0400)
Renaming the eventRegistrantList view file to appView.

js/eventRegApp.js
js/views/appView.js [new file with mode: 0644]
js/views/eventRegistrantList.js [deleted file]
models/front/registrations/registration.php

index 0c26225..6bf10ea 100644 (file)
@@ -9,6 +9,6 @@ app.EventRegistrants = new app.EventRegistrantList();
 
 jQuery(document).ready(function($){
 
-    new app.EventRegistrantListView();
+    new app.AppView();
 
 });
diff --git a/js/views/appView.js b/js/views/appView.js
new file mode 100644 (file)
index 0000000..4c7aa7f
--- /dev/null
@@ -0,0 +1,67 @@
+// js/views/appView.js
+var app = app || {};
+
+// Event Registrant List View
+app.AppView = Backbone.View.extend({
+
+    el: '.glm-reg-level',
+
+    initialize: function(){
+        this.$newName  = this.$('.addName');
+        this.$newEmail = this.$('.addEmail');
+
+        this.listenTo( app.EventRegistrants, 'add', this.addOne );
+        this.listenTo( app.EventRegistrants, 'reset', this.addAll );
+        app.EventRegistrants.fetch();
+        //this.collection.bind('add', this.onModelAdded, this);
+        //this.render();
+    },
+
+    deleteOne: function( el ){
+        console.log( el );
+        console.log( 'deleteOne called on listView' );
+        //app.EventRegistrants.fetch();
+    },
+
+    events: {
+        'click .addRegistrant': 'newEntry',
+    },
+
+    newEntry: function(){
+        if ( !this.$newName.val().trim() || !this.$newEmail.val().trim() ) {
+            return;
+        }
+        var emailMatches = app.EventRegistrants.where({email: this.$newEmail.val().trim()});
+        app.EventRegistrants.create( this.newAttributes() );
+        this.$newName.val('');
+        this.$newEmail.val('');
+    },
+
+    newAttributes: function(){
+        return {
+            name: this.$newName.val().trim(),
+            email: this.$newEmail.val().trim()
+        };
+    },
+
+    addOne: function(item){
+        if ( item.isValid() ) {
+            var view = new app.EventRegistrantView({ model: item });
+            this.$el.append( view.render().el );
+        }
+    },
+
+    addAll: function(){
+        this.$('.glm-reg-level').html('');
+        app.EventRegistrants.each(this.addOne, this);
+    },
+
+    render: function(){
+        var eventRegistrantView = this.collection.map(function(item){
+            return (new app.EventRegistrantView({ model: item })).render().el;
+        });
+        this.$el.append(eventRegistrantView);
+        return this;
+    },
+
+});
diff --git a/js/views/eventRegistrantList.js b/js/views/eventRegistrantList.js
deleted file mode 100644 (file)
index a355aee..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-// js/views/eventRegistrantList.js
-var app = app || {};
-
-// Event Registrant List View
-app.EventRegistrantListView = Backbone.View.extend({
-
-    el: '.glm-reg-level',
-
-    initialize: function(){
-        this.$newName  = this.$('.addName');
-        this.$newEmail = this.$('.addEmail');
-
-        this.listenTo( app.EventRegistrants, 'add', this.addOne );
-        this.listenTo( app.EventRegistrants, 'reset', this.addAll );
-        app.EventRegistrants.fetch();
-        //this.collection.bind('add', this.onModelAdded, this);
-        //this.render();
-    },
-
-    deleteOne: function( el ){
-        console.log( el );
-        console.log( 'deleteOne called on listView' );
-        //app.EventRegistrants.fetch();
-    },
-
-    events: {
-        'click .addRegistrant': 'newEntry',
-    },
-
-    newEntry: function(){
-        if ( !this.$newName.val().trim() || !this.$newEmail.val().trim() ) {
-            return;
-        }
-        var emailMatches = app.EventRegistrants.where({email: this.$newEmail.val().trim()});
-        app.EventRegistrants.create( this.newAttributes() );
-        this.$newName.val('');
-        this.$newEmail.val('');
-    },
-
-    newAttributes: function(){
-        return {
-            name: this.$newName.val().trim(),
-            email: this.$newEmail.val().trim()
-        };
-    },
-
-    addOne: function(item){
-        if ( item.isValid() ) {
-            var view = new app.EventRegistrantView({ model: item });
-            this.$el.append( view.render().el );
-        }
-    },
-
-    addAll: function(){
-        this.$('.glm-reg-level').html('');
-        app.EventRegistrants.each(this.addOne, this);
-    },
-
-    render: function(){
-        var eventRegistrantView = this.collection.map(function(item){
-            return (new app.EventRegistrantView({ model: item })).render().el;
-        });
-        this.$el.append(eventRegistrantView);
-        return this;
-    },
-
-});
index a8c8800..d91acc9 100644 (file)
@@ -40,7 +40,7 @@
         $scripts = array(
             'backbone-local'     => 'js/lib/backbone.localStorage.min.js',
             'registrantView'     => 'js/views/eventRegistrant.js',
-            'registrantListView' => 'js/views/eventRegistrantList.js',
+            'appView'            => 'js/views/appView.js',
             'registrantModel'    => 'js/models/eventRegistrant.js',
             'registrantList'     => 'js/collections/eventRegistrantList.js',
             'mybackboneapp'      => 'js/eventRegApp.js',