0
我在我的.ts(.js)文件中有一个单击事件。当用户点击时,我正在调用ajax来获取数据。成功后,我绑定这些数据来创建动态kendo网格(网格数量根据数据而不同)。如何在文档准备好执行部分代码?
执行事件后,我想执行一些代码。但在执行此代码时,特定的网格不可用。如何等待,直到网格可用然后执行此代码? jquery文档准备在同一个点击事件中不起作用。
$(chkBox).click(() => {
var chk = $(event.target);
var val = chk.val();
if (chk.prop("checked")) {
// code removed for bravity
proxyEle.getData(myObject).done(result => {
// this div has partial view which binds data from result.
$(divGrids).html(<string>result); // this part creates kendo grids dynamcially based on data.
// here I want to execute my code on the grid elements
//but this code is executing before grid creation is complete.
//So my code is not working. Why here? My grid ids are
// like "SomeConstName"+chk.val(); this val() I only get here.
}).fail(error => {
// handle error
});
}
}
为什么要在那里执行我的代码?因为我使用网格ID作为“ConstGridName”+ chk.value();
这个Id值我在上面的代码。这就是为什么我想在那里执行我的代码。如何延迟我的代码执行,直到所有网格都准备好了?