Renaming the eventRegistrantList view file to appView.
jQuery(document).ready(function($){
- new app.EventRegistrantListView();
+ new app.AppView();
});
--- /dev/null
+// 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;
+ },
+
+});
+++ /dev/null
-// 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;
- },
-
-});
$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',