From dff40cd759ea35fee581f2474ecbf4a10f19520a Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Tue, 19 Dec 2017 16:48:45 -0500 Subject: [PATCH] WIP working on the update registrant 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 | 29 ++++++++++++--------- js/models/front/regRequestRegistrant.js | 1 + js/views/front/regRequestRegistrant.js | 28 +++++++++++--------- models/admin/ajax/regFront/registrant.php | 1 + views/front/registrations/registration.html | 1 + 5 files changed, 34 insertions(+), 26 deletions(-) diff --git a/js/frontRegApp.js b/js/frontRegApp.js index f628e90..1fcfd05 100644 --- a/js/frontRegApp.js +++ b/js/frontRegApp.js @@ -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 ); // } diff --git a/js/models/front/regRequestRegistrant.js b/js/models/front/regRequestRegistrant.js index 167a9d1..1dcca8c 100644 --- a/js/models/front/regRequestRegistrant.js +++ b/js/models/front/regRequestRegistrant.js @@ -25,6 +25,7 @@ app.Models.Front.RegRequestRegistrant = Backbone.Model.extend({ state: '', zip: '', country: '', + customFields: '', }, // url used for ajax request diff --git a/js/views/front/regRequestRegistrant.js b/js/views/front/regRequestRegistrant.js index e551c06..96d0399 100644 --- a/js/views/front/regRequestRegistrant.js +++ b/js/views/front/regRequestRegistrant.js @@ -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 ); // } diff --git a/models/admin/ajax/regFront/registrant.php b/models/admin/ajax/regFront/registrant.php index c2afa95..a2da754 100644 --- a/models/admin/ajax/regFront/registrant.php +++ b/models/admin/ajax/regFront/registrant.php @@ -513,6 +513,7 @@ class GlmMembersAdmin_registrations_ajax_registrant extends GlmDataRegistrations $regRequestRegistrantId, true ); + $registrant['customFields'] = $modelData['customFields']; return $registrant; diff --git a/views/front/registrations/registration.html b/views/front/registrations/registration.html index ebdba5c..1364494 100644 --- a/views/front/registrations/registration.html +++ b/views/front/registrations/registration.html @@ -366,6 +366,7 @@ var app = { 'formData': false }; $.ajax({ + cache: false, type: 'POST', url: ajaxUrl, data: formData, -- 2.17.1