Created
April 16, 2015 05:16
-
-
Save maranemil/f8920962ae9ee9b0d8ce to your computer and use it in GitHub Desktop.
SugarCRM7 Add DropDown List - Populate list with ajax
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
// 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