Cached data on click map

157
4
Jump to solution
07-26-2020 11:47 PM
Vakhtang_Zubiashvili
Occasional Contributor

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();
}
});

}
});
});‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Esteemed Contributor

In your buttons click event I would use 

var folder_name = 'inv_images/' + view.popup.selectedFeature.attributes.Wis_invent_N;

View solution in original post

4 Replies
RobertScheitlin__GISP
MVP Esteemed Contributor

In your buttons click event I would use 

var folder_name = 'inv_images/' + view.popup.selectedFeature.attributes.Wis_invent_N;

View solution in original post

Vakhtang_Zubiashvili
Occasional Contributor

Thanks Robert, 

It works great.

in this case It uses popup value right?

0 Kudos
RobertScheitlin__GISP
MVP Esteemed Contributor

Correct

Vakhtang_Zubiashvili
Occasional Contributor

Thank yo again

0 Kudos