尝试利用$.get()
,追加响应于.k-content
,在响应滤波所选section
元件的id
克隆,添加字符到id
防止重复id
的在DOM
,.Placeafterthis
后插入;定义getSections
组与jQuery承诺对象this
,递归调用getSections
对sections
阵列返回Array.prototype.shift()
为每个项目在索引0
为了回报$.get()
,否则,如果在section[0]
回报this.promise()
// `id`s of `section` elements to append to `.k-content`
var sections = ["#id1", "#id2", "#id3"];
// selected `id` to do stuff with
var selected = sections[1];
// container
var container = $(".k-content");
// `complete` handler for `$.get()` requests
function selectedId(html, textStatus, jqxhr) {
// decode `data` : `id` sent with request
var id = decodeURIComponent(this.url.split("?")[1]).split("=")[1];
// append `section` to `container`
container.append($(html).filter(id));
// if `selected` appended to `container` ,
// and `selected` is not in `DOM` directly after `.Placeafterthis` element
// clone `selected` , append after `.Placeafterthis` element
if (container.find(selected).is("*")
&& !$(".Placeafterthis + " + selected + "-a").is("*")) {
var clone = $(selected, container).clone()
.attr("id", selected.slice(1) + "-a");
$(".Placeafterthis").after(clone)
}
}
var getSections = function getSections() {
var p = sections.shift();
return !!sections
&& $.get("http://fiddle.jshell.net/guest271314/rvt8evoy/show/"
, {"id": p}, selectedId).then(getSections)
};
getSections()
.then(function() {
console.log("complete")
})
的jsfiddle返回由!!
运营商false
http://jsfiddle.net/1d6vmdpt/5/
如何将内容绑定到这些div?你有没有使用一些Ajax调用,角? –
我没有做绑定。这已经完成了。我只想获得该部分的准备好或加载的事件。 – Neophile
部分,图像,iframe中的内容是什么类型? – DavidDomain