Combo

I have a combo and i want to load the options dinamially. But it is not working. What am i doing wrong?

$$(“estado”).attachEvent(“onItemClick”, function() {
webix.ajax().post("…/rest/estados/loadAll", “”,{
error: function(text, xml, XmlHttpRequest) {
webix.message("error:
" + text);
},
success: function(text, xml, XmlHttpRequest) {
var list = $$(“estado”).getPopup().getList();
list.clearAll();
list.define(“options”, “[{id: ‘#sigla#’, value: ‘#nome#’}]”);
list.parse(text);
list.refresh();
}
});
});

I also want to load it after page render but when i try to use onAfterLoad event, it is not working it dont even fire the event.

Eduard

Hi Eduard,

Are you getting the correct data in the response? Also, you needn’t call define() for the list, it doesn’t feature ‘options’ property (combo does). And refreshing is optional as well.

Please, check the following code snippet: http://webix.com/snippet/507eb114

As to the moment of loading, you can catch combo’s “onAfterRender” event and issue an Ajax request there. Use webix.once() wrapper function to ensure the request is sent only the first time combo is rendered.