Skip to content

Instantly share code, notes, and snippets.

@maranemil
Created April 16, 2015 05:16
Show Gist options
  • Save maranemil/f8920962ae9ee9b0d8ce to your computer and use it in GitHub Desktop.
Save maranemil/f8920962ae9ee9b0d8ce to your computer and use it in GitHub Desktop.
SugarCRM7 Add DropDown List - Populate list with ajax
// by EvilPeri
//custom/modules/<your module>/clients/base/fields/enum/enum.js
({
extendsFrom: 'EnumField',
_render: function(){
if(this.name == 'your field name here'){
if(_.isEmpty(this.items)){
this.setItems();
return;
}
}
this._super('_render');
}.
setItems: function(){
if(!_.isEmpty(this.items)){
this._render();
}
//add ajax to retrieve dropdown from another source
// this is just an example
$.ajax({
url: <your url here>
type: POST | GET | PUT | DELETE,
success: _.bind(function(data){
this.items = data;
//or do whatever data manipulation you want here.
//just as long as the this.items is an array
this.render();
},this);
})
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment