AnsweredAssumed Answered

Extending create.js on module level is not working

Question asked by Juan Juan on Jun 10, 2014
Latest reply on Jun 11, 2014 by Juan Juan
Hi there,

I am currently working on SugarCrm 7.2 and having an issue with extending create.js on module level.

I just want to add an event like "keypress" and "keydown" on an input field in create view. if I added related code  at /clients/base/views/create/create.js as below and it is working as expected.
1) new event in initialize function 
initialize: function (options) {       
        var createViewEvents = {};
        createViewEvents['click a[name=' + this.saveButtonName + ']:not(.disabled)'] = 'save';
        createViewEvents['click a[name=' + this.cancelButtonName + ']'] = 'cancel';
        createViewEvents['click a[name=' + this.saveAndCreateButtonName + ']:not(.disabled)'] = 'saveAndCreate';
        createViewEvents['click a[name=' + this.saveAndViewButtonName + ']:not(.disabled)'] = 'saveAndView';
        createViewEvents['click a[name=' + this.restoreButtonName + ']:not(.disabled)'] = 'restoreModel';
       /* the new event was added here*/
        createViewEvents['keypress input[name=search]:not(.disabled)'] = 'search';
       
        this.events = _.extend({}, this.events, createViewEvents);

2) add new function search
search: function () {
},

However if I move this code to  /custom/modules/[related-module]/clients/base/create/create.js as blow and it is not working any more.
({
    extendsFrom: 'CreateView',
    events:{
     'keypress input[name=search]:not(.disabled)':'search',
    },
    initialize: function (options) {
       
        this._super('initialize', [options]);
        this.events = _.extend( {}, CreateView.prototype.events, this.events );
    },
    search: function () {
    },
    _dispose: function() {
        //additional stuff before calling the core create _dispose goes here
        this._super('_dispose');
    }


})

I found that I  put the related code in create-action.js and it is working fine. 

just wondering if anyone have working with create.js before and could give me some suggestions? Thanks in advance.

Cheers,
Juan

Outcomes