From: Steve Sutton Date: Thu, 24 Aug 2017 16:08:42 +0000 (-0400) Subject: Getting ready to organize again. X-Git-Tag: v1.0.0^2~445 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/index.cgi?a=commitdiff_plain;h=cdc0937e6732ea182d330a911a94b47e52d9102a;p=WP-Plugins%2Fglm-member-db-registrations.git Getting ready to organize again. Saving these changes as this part is working. Will be re-organizing the files for each needed model, collection and view for the app. --- diff --git a/js/models/account.js b/js/models/account.js new file mode 100644 index 0000000..3117d2b --- /dev/null +++ b/js/models/account.js @@ -0,0 +1,42 @@ +// js/models/account.js + +var app = app || {}; + +// Account Model +app.account = Backbone.Model.extend({ + + // Default account values + defaults: { + active: true, + registered_by: 0, + fname: '', + lname: '', + org: '', + title: '', + addr1: '', + addr2: '', + city: '', + state: '', + zip: '', + phone: '', + email: '', + }, + + initialize: function(){ + this.on('invalid', function( model, error ){ + console.log( error ); + }); + }, + + validate: function(){ + if ( attribs.fname === undefined || attribs.fname === '' ) { + return 'First name empty!'; + } + if ( attribs.lname === undefined || attribs.lname === '' ) { + return 'Last name empty!'; + } + if ( attribs.email === undefined || attribs.email === '' ) { + return 'Need an email address!'; + } + }, +}); diff --git a/js/models/eventRegistrant.js b/js/models/eventRegistrant.js index b6006f2..d618b55 100644 --- a/js/models/eventRegistrant.js +++ b/js/models/eventRegistrant.js @@ -13,7 +13,7 @@ app.EventRegistrant = Backbone.Model.extend({ initialize: function(){ this.on( 'invalid', function( model, error ){ - console.log(error); + console.log( error ); }); }, diff --git a/js/views/app.js b/js/views/app.js index d48e687..f5656e3 100644 --- a/js/views/app.js +++ b/js/views/app.js @@ -13,14 +13,11 @@ app.AppView = Backbone.View.extend({ 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: { diff --git a/views/front/registrations/registration.html b/views/front/registrations/registration.html index 647c025..547b526 100644 --- a/views/front/registrations/registration.html +++ b/views/front/registrations/registration.html @@ -1,3 +1,6 @@ +
+ +
{* Event Registration App - Backbone.js *}
{* Underscore Templates for the Event Registration App *} @@ -21,6 +24,15 @@ + + {/literal}
{$event = $entry.reg_event}