In my project I have a table, each of its rows holding id and title as data attributes
<tr data-id="1" data-title="title"><td id="td_title">some text</td></tr>
I use jQuery to update the data-tile attribute
$newTitle = 'newTitle';
$row_to_update = $("tr").find("[data-id='1']");
$row_to_update.attr('data-title', newTitle );
So after that, in the html I can see the updated values, but if I try this:
$var = $row_to_update.data('title');
alert($var);
It returns the old title, unless I load the page again.
I suppose I have to clear the cache, but I only found $.domCache
, which is not applicable to jQuery and also saw and tried
function clearjQueryCache(){
for (var x in jQuery.cache){
delete jQuery.cache[x];
}
}
but obviously not correct, as everything stopped working