Hi all, Robert Scheitlin, GISP
I use ajax in Arcgis Javascript and hitTest to select some data and show it in modal window (these are uploaded images on server side in folders, each feature in map layer is connected to these folders using Wis_invent_N), but i have problem, e.g. i clicked several feature on map (e.g. 3 features) and on each click on map i get different info, but if i click info button (i have these button in popup window) again and again it shows these selected features one by one even though i have selected different feature on map, it stores data and does not show correct info when i continue click and get info from a map.
I use 'cache: false' in $.ajax but it's not working.
here is a piece of code i use
view.on("click", function (event) {
view.hitTest(event).then(function (response) {
if (response.results.length) {
var graphic = response.results.filter(function (result) {
return result.graphic.layer === Wa;
})[0].graphic;
//console.log(graphic.attributes);
$(document).on('click', '#vf', function() // see uploaded images
{
var folder_name = 'inv_images/' + graphic.attributes.Wis_invent_N;
var action = "fetch_files";
$.ajax({
cache: false,
url: "action.php",
method: "POST",
data:{action:action, folder_name:folder_name},
success: function(data)
{
$('#file_list').html(data);
$('#filelistModal').modal('show');
}
})
});
var openFilebtn = document.getElementById("vf");
function openFilesbtn(){openFilebtn.click()};
view.popup.on("trigger-action", function(event) {
if (event.action.id === "filelist") {
openFilesbtn();
}
});
}
});
});
Solved! Go to Solution.
In your buttons click event I would use
var folder_name = 'inv_images/' + view.popup.selectedFeature.attributes.Wis_invent_N;
In your buttons click event I would use
var folder_name = 'inv_images/' + view.popup.selectedFeature.attributes.Wis_invent_N;
Thanks Robert,
It works great.
in this case It uses popup value right?
Correct
Thank yo again