get json 関数によって要素にデータを追加するこのスクリプトがあります。
$(document).ready(function() {
ADD.Listitem.get();
});
基本的に、データなどを含む一連のhtmlタグを追加します。私が抱えている問題は次のとおりです。
$(document).ready(function() {
ADD.Listitem.get();
var arr = [];
$(".Listitem-section-item-title").each(function() {
arr.push($(this.text()));
});
});
-
get: function(web) {
AST.Utils.JSON.get("/_vti_bin/AST/ListItem/ListitemService.svc/GetListItem", null, AST.Listitem.renderListitem);
},
renderListitem: function(data) {
$("#Listitem-template").tmpl(data["ListItemResults"]).prependTo(".ListItem-section-template");
}
そしてここにjson getがあります:
ADD.Utils.JSON.get = function (url, data, onSuccess) {
$.ajax({
type: "GET",
contentType: "application/json; charset=utf-8",
async: true,
url: url,
data: data,
cache: false,
dataType: "json",
success: onSuccess,
error: ADD.Utils.JSON.error,
converters: { "text json": ADD.Utils.JSON.deserialize }
});
}
getメソッドがセレクターのレンダリングを終了していないため、各ループの配列は実行されていないListitem-section-item-title
ため、セレクターを見つけることができません。
これに対する良い解決策はありますか?