Created
October 5, 2016 20:14
-
-
Save zachskaggs/e1a58abcb52f24bf80ae4eac4448f59a 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 code. | |
var myCustomFieldController = Marionette.Object.extend( { | |
initialize: function() { | |
this.listenTo( Backbone.Radio.channel( 'app' ), 'after:loadControllers', this.changeValue ); | |
}, | |
changeValue: function() { | |
var model = Backbone.Radio.channel( 'form-109' ).request( 'get:fieldByKey', 'textbox' ); //use your form number in place of '109' here. Replace 'textbox' with your field key. Field key must be unique per form and page, should a page contain multiple forms | |
if ( model ) { | |
model.set( 'value', 'foo' ); // Update the value. Replace 'foo' with your value | |
} | |
} | |
}); | |
jQuery( document ).ready( function() { | |
new myCustomFieldController(); | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment