If I have code that pulls down a jQuery object, and then makes some further calls on it
$("a.postSyncLink").click(function () {
var resultsTarget = $("span", $(link).parent().next());
resultsTarget.html("<img style='position: absolute;' src='" + waitImgUrl + "'/><span>Sync in progress</span>");
$.get($(this).attr("data-url"), function (returnVal) {
resultsTarget.text(returnVal);
});
});
Is it considered bad practice to subsequently (and unnecessarily) wrap that object in the jQuery function? Does jQuery optimize superfluous calls like this?
$("a.postSyncLink").click(function () {
var resultsTarget = $("span", $(link).parent().next());
$(resultsTarget).html("<img style='position: absolute;' src='" + waitImgUrl + "'/><span>Sync in progress</span>");
$.get($(this).attr("data-url"), function (returnVal) {
$(resultsTarget).text(returnVal);
});
});
Source: Tips4all
No comments:
Post a Comment