I'm using asp.net core and MVC architecture. I have a jquery event handler on a button click. If the user click the button, I apply different change to the DOM, based on data I fetch from my c# model. The data I need from my model change depending on user input. But as the event handler is only executed at launch time, the data from my model in it reflect the initial state of my model.
My javascript :
$(document).on("click", ".edit-log-child", function () {
var NameCategory = $(this).data('id');
/*some DOM change*/
var json = @Json.Serialize(@Model.Categories);
if (JSON.stringify(json) != JSON.stringify("{[]}"))
{
var currentCategory = json.find(element => element.name == NameCategory);
ProcessEditCategorie(currentCategory);
}
});
Is there a way to fetch my current model from my javascript function/event handler ?