Created
October 26, 2016 18:01
-
-
Save kstover/de626edd24568aed04f236722cca31c6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create a new object for custom validation of a custom field. | |
var mySubmitController = Marionette.Object.extend( { | |
initialize: function() { | |
this.listenTo( Backbone.Radio.channel( 'field-4', 'change:field', this.nameChange ) ); | |
}, | |
nameChange: function( el, model ) { | |
// Split your model value | |
var value = model.get( 'value' ); | |
var firstNameValue = ''// First name logic | |
var lastNameValue = ''// Last name logic | |
// Get our first name model and update the value where 5 is the field ID | |
var firstNameModel = Backbone.Radio.channel( 'fields' ).request( 'get:field', 5 ); | |
firstNameModel.set( 'value', firstNameValue ); | |
// Get our last name model and update the value where 6 is the field ID | |
var lastNameModel = Backbone.Radio.channel( 'fields' ).request( 'get:field', 6 ); | |
lastNameModel.set( 'value', lastNameValue ); | |
}, | |
}); | |
// On Document Ready... | |
jQuery( document ).ready( function( $ ) { | |
// Instantiate our custom field's controller, defined above. | |
new mySubmitController(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment