I don't use jquery much - but i have the need to fix some code in a "lighter" (and a bit older) UI for a larger solution.
It uses mix of various libraries - including jquery.
$("."+vehicleId+"_popupAddressCell").html(address);
is used to set the value for the field. It works - as long as its inside the:
success:{}
of a Ajax call. Right after the ajax call it fails. Logging it to console (without .html part) - shows that it didn't select anything - length 0. However i can navigate to that correct element in the children tree.
Why would it not select it, even tho it exist in its context-childNodes and only difference i see when i echo both is that... outside ajax it didn't select it. The vehicleId is not an ajax result nether is address ( instead of it it would be 'result') - those two variables exist in proper scope and are accessible.
updatePopup: function(vehicle) {
var lat = vehicle.location()[0];
var lon = vehicle.location()[1];
var vehicleId = vehicle.id;
var address = vehicle.address();
Air.Ajax.request({
url: 'Api/Objects/get',
data: {
lat: lat,
lon: lon
},
success: function(response) {
$("."+vehicleId+"_popupAddressCell").html(response);
console.log($("."+vehicleId+"_popupAddressCell"));
},
scope: this
});
$("."+vehicleId+"_popupAddressCell").html(address);
console.log($("."+vehicleId+"_popupAddressCell"));
}
added above console.log test cases - the one inside success:
0: td.9880_popupAddressCell
context: document
length: 1
prevObject: x.fn.x.init[1]
selector: ".9880_popupAddressCell"
outside one would have:
context: document
length: 0
prevObject: x.fn.x.init[1]
selector: ".9880_popupAddressCell"