WIP working on the update registrant
authorSteve Sutton <steve@gaslightmedia.com>
Tue, 19 Dec 2017 21:48:45 +0000 (16:48 -0500)
committerSteve Sutton <steve@gaslightmedia.com>
Tue, 19 Dec 2017 21:48:45 +0000 (16:48 -0500)
Trying to get the custom field data to refresh when saved.
It is saving the new field data just doesn't want to refresh to the
registrant.

js/frontRegApp.js
js/models/front/regRequestRegistrant.js
js/views/front/regRequestRegistrant.js
models/admin/ajax/regFront/registrant.php
views/front/registrations/registration.html

index f628e90..1fcfd05 100644 (file)
@@ -245,6 +245,7 @@ app.Models.Front.RegRequestRegistrant = Backbone.Model.extend({
         state: '',
         zip: '',
         country: '',
+        customFields: '',
     },
 
     // url used for ajax request
@@ -752,16 +753,8 @@ app.Views.Front.RegRequestRegistrant = Backbone.View.extend({
 
     // used to setup initial class
     initialize: function(){
-        this.listenTo( this.model, 'change', this.render );
-
-        // Call the custom fields ajax
-        // if ( this.model.id ) {
-        //     this.customFieldFormData = app.setCustomFieldsForm(
-        //         this.model.get('reg_event'),
-        //         this.model.id,
-        //         'return'
-        //     );
-        // }
+        // this.listenTo( this.model, 'change', this.render );
+        this.listenTo( this.model, 'change:customFields', this.resetCustomFields );
 
         return this;
     },
@@ -810,6 +803,7 @@ app.Views.Front.RegRequestRegistrant = Backbone.View.extend({
         // Get the form values and update the model.
         this.model.set({
             option: 'update',
+            id: this.model.get('id'),
             reg_request: this.model.get('reg_request'),
             reg_event: this.model.get('reg_event'),
             reg_class: this.model.get('reg_class'),
@@ -829,10 +823,16 @@ app.Views.Front.RegRequestRegistrant = Backbone.View.extend({
             // console.log( this.model.validationError );
         }
 
-        this.$('.reg-edit-form').hide();
+        // this.$('.reg-edit-form').hide();
         app.regEventLock = false;
     },
 
+    resetCustomFields: function() {
+        // Call the custom fields ajax
+        app.setCustomFieldsForm(this.model.get('reg_event'), this.model.id, '.attendee-cf-' + this.model.id);
+        this.$('.reg-edit-form').hide();
+    },
+
     toggleClass: function(){
         this.$('.ereg-addr').toggle();
     },
@@ -859,12 +859,15 @@ app.Views.Front.RegRequestRegistrant = Backbone.View.extend({
 
     // render the view
     render: function(){
-        // Call the custom fields ajax
-        app.setCustomFieldsForm(this.model.get('reg_event'), this.model.id, '.attendee-cf-' + this.model.id);
+        // console.log( 'regReguestRegistrantView.render called' );
 
         this.$el.html( this.template( this.model.toJSON() ) );
         this.$emailInput = this.$('.editEmail');
         this.$('.reg-edit-form').hide();
+
+        // Call the custom fields ajax
+        app.setCustomFieldsForm(this.model.get('reg_event'), this.model.id, '.attendee-cf-' + this.model.id);
+        // console.log('call setCustomFieldsForm' );
         // if ( this.customFieldFormData ) {
         //     this.$('.attendee-cf-' + this.model.get('id')).html( this.customFieldFormData );
         // }
index 167a9d1..1dcca8c 100644 (file)
@@ -25,6 +25,7 @@ app.Models.Front.RegRequestRegistrant = Backbone.Model.extend({
         state: '',
         zip: '',
         country: '',
+        customFields: '',
     },
 
     // url used for ajax request
index e551c06..96d0399 100644 (file)
@@ -7,16 +7,8 @@ app.Views.Front.RegRequestRegistrant = Backbone.View.extend({
 
     // used to setup initial class
     initialize: function(){
-        this.listenTo( this.model, 'change', this.render );
-
-        // Call the custom fields ajax
-        // if ( this.model.id ) {
-        //     this.customFieldFormData = app.setCustomFieldsForm(
-        //         this.model.get('reg_event'),
-        //         this.model.id,
-        //         'return'
-        //     );
-        // }
+        // this.listenTo( this.model, 'change', this.render );
+        this.listenTo( this.model, 'change:customFields', this.resetCustomFields );
 
         return this;
     },
@@ -65,6 +57,7 @@ app.Views.Front.RegRequestRegistrant = Backbone.View.extend({
         // Get the form values and update the model.
         this.model.set({
             option: 'update',
+            id: this.model.get('id'),
             reg_request: this.model.get('reg_request'),
             reg_event: this.model.get('reg_event'),
             reg_class: this.model.get('reg_class'),
@@ -84,10 +77,16 @@ app.Views.Front.RegRequestRegistrant = Backbone.View.extend({
             // console.log( this.model.validationError );
         }
 
-        this.$('.reg-edit-form').hide();
+        // this.$('.reg-edit-form').hide();
         app.regEventLock = false;
     },
 
+    resetCustomFields: function() {
+        // Call the custom fields ajax
+        app.setCustomFieldsForm(this.model.get('reg_event'), this.model.id, '.attendee-cf-' + this.model.id);
+        this.$('.reg-edit-form').hide();
+    },
+
     toggleClass: function(){
         this.$('.ereg-addr').toggle();
     },
@@ -114,12 +113,15 @@ app.Views.Front.RegRequestRegistrant = Backbone.View.extend({
 
     // render the view
     render: function(){
-        // Call the custom fields ajax
-        app.setCustomFieldsForm(this.model.get('reg_event'), this.model.id, '.attendee-cf-' + this.model.id);
+        // console.log( 'regReguestRegistrantView.render called' );
 
         this.$el.html( this.template( this.model.toJSON() ) );
         this.$emailInput = this.$('.editEmail');
         this.$('.reg-edit-form').hide();
+
+        // Call the custom fields ajax
+        app.setCustomFieldsForm(this.model.get('reg_event'), this.model.id, '.attendee-cf-' + this.model.id);
+        // console.log('call setCustomFieldsForm' );
         // if ( this.customFieldFormData ) {
         //     this.$('.attendee-cf-' + this.model.get('id')).html( this.customFieldFormData );
         // }
index c2afa95..a2da754 100644 (file)
@@ -513,6 +513,7 @@ class GlmMembersAdmin_registrations_ajax_registrant extends GlmDataRegistrations
             $regRequestRegistrantId,
             true
         );
+        $registrant['customFields'] = $modelData['customFields'];
 
         return $registrant;
 
index ebdba5c..1364494 100644 (file)
@@ -366,6 +366,7 @@ var app = {
                 'formData': false
             };
             $.ajax({
+                cache: false,
                 type: 'POST',
                 url: ajaxUrl,
                 data: formData,