AnsweredAssumed Answered

How do you add onchange to record view in Sugar 7?

Question asked by Mike Solomon on Jun 9, 2014
Latest reply on Oct 2, 2015 by Juho Heikkilä
Adding javascript onchange, onfocus etc. was easy in 6.5 you just added the event to editviewdefs.php

I am having problems working out how todo it in 7.2

I've tried creating a record.js file with the following code

extendsFrom: 'RecordView',
initialize: function(options) {
     app.view.invokeParent(this, {type: 'view', name: 'record', method: 'initialize', args:[options]});
      this.model.on("change:billing_address_street",this.miketest, this); 
    var val = this.model.get('billing_address_street');
This gives me the alert but it fires when the record loads before the billing address has been changed.

I also tried wrapping the code in a $(document).on("ready", function but then it doesn't fire at all

Then tried adding  the onchange :
     $('[name="name"]').change(function() {
alert( "Test" );
But that also doesn't work

Any help in doing this would be much appreciated