0

igcombo works fine when using a static div element, however if I added the div element dynamically to the page the igcombo box data won't be populated. Is there any thing I can try to make this work?

 $("#combo").igCombo({
            dataSource: data, //JSON Array 
            valueKey: "ID",
            textKey: "Name"
        });



<div id="combo"></div>
Konstantin Dinev
  • 34,219
  • 14
  • 75
  • 100
tomreha
  • 11
  • 1

1 Answers1

1

The igCombo and any other widget needs to be initialized on an element that already exists in the DOM. In order to have it work with a container that you create dynamically, you simply need to call the initialization code after the element is added to the DOM.

$.ajax({
    ...
    success: function (data) {
        var combo = $('<div id="combo"></div>').appendTo(document.body);
        combo.igCombo({
            dataSource: data, //JSON Array 
            valueKey: "ID",
            textKey: "Name"
        });
    }
});
Konstantin Dinev
  • 34,219
  • 14
  • 75
  • 100