Skip to content

Instantly share code, notes, and snippets.

@kjohnson
Last active September 22, 2016 14:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kjohnson/9c6f6764bdb8c45c15b1db391afcc365 to your computer and use it in GitHub Desktop.
Save kjohnson/9c6f6764bdb8c45c15b1db391afcc365 to your computer and use it in GitHub Desktop.
// Create a new object for custom validation of a custom field.
var myCustomFieldController = Marionette.Object.extend( {
initialize: function() {
// Listen to the render:view event for a field type. Example: Textbox field.
this.listenTo( nfRadio.channel( 'textbox' ), 'render:view', this.renderView );
},
renderView: function( view ) {
// Check if this is the right field. Example check for field key.
if ( 'example_key' != view.model.get( 'key' ) ) return false;
var el = jQuery( view.el ).find( '.nf-element' );
// Do stuff.
}
});
// On Document Ready...
jQuery( document ).ready( function( $ ) {
// Instantiate our custom field's controller, defined above.
new myCustomFieldController();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment