I have the following code:
$(\"#scheduleLink\").trigger(\"click\");
alert(\"text\")
This is the click handler:
$(\"#scheduleL
Looks like there are 3 solutions:
1 - Create a function, and invoke it from a callback on .load
function loadComplete() {
alert("text");
}
$("#scheduleLink")
.on("click", function () {
$("#publicationBlockContent")
.load("/my-url", function () {
loadComplete();
});
})
.trigger("click");
2 - Bind a custom event to $("#scheduleLink") called "loadComplete", and trigger it from a callback on .load
$("#scheduleLink")
.on("loadComplete", function () {
alert("text");
})
.on("click", function () {
$("#publicationBlockContent")
.load("/my-url", function () {
$("#scheduleLink").trigger("loadComplete");
});
})
.trigger("click");
3 - If you don't need a .load, you can use the promise object supported by $.ajax, $.get and $.post
$("#scheduleLink")
.on("click", function () {
return $.get("/my-url", function () {
$("#scheduleLink").trigger("loadComplete");
});
})
.trigger("click");
var promise = $("#scheduleLink").triggerHandler("click");
promise && promise.done(function () {
alert("click");
});