Hi, @create-28
Thank you for your question.
You may be able to do this with window.location.reload(); just before if( Number( list_post_num ) < 1 ) { in line 95 of “/assets/list.js“.
94 $('#'+ count_post).children('.number').text(list_post_num);
95 window.location.reload(); // Add this code.
96 if( Number( list_post_num ) < 1 ) {
You can try it by setting up a development environment. I don’t recommend using it on a public theme right away.
Thanks
Hi, thats worked, but when it reloaded, it didn’t actually remove the item from the list, it was still there, would a timeout work or something?
Regards,
Paul
Hi, Paul ( @create-28 )
Thanks for your reply.
Which list has not been updated?
Is it the standard list for this plugin? Or is it your own list?
If what you are talking about is the standard list, then you might try the timeout as you mentioned.
95 setTimeout( function() {
96 window.location.reload(); // Add this code.
97 },600);
/*
// Please comment out.
if( Number( list_post_num ) < 1 ) {
setTimeout( function() {
...
},600);
} //endif
*/
However, when I tested it in my environment, the standard list was updated without timeout.
Regards,
Takashi
Hi, its the standard list, so by Default, when you remove an item it sets css display none and also removes the item from the users list. So if they refresh the page the item is not there.
The problem is when i click remove item with this reload function, it hides it with css, then reloads the page but the item is still there when it’s reloaded. so its not updating the actual users list.
I have used the code you sent like this below:
However I think its the local storage not registering the item being removed?
Regards,
Paul
my_promise.done( function() {
found_posts_count_val = $('.ccc-favorite-post-count').find('.num').text();
$('#'+ count_post).children('.found_posts').text(found_posts_count_val);
var list_post_num = $('.'+ list_post).filter(':visible').length;
$('#'+ count_post).children('.number').text(list_post_num);
setTimeout( function() {
window.location.reload(); // Add this code.
},600);
});
}
/* if( Number( list_post_num ) < 1 ) {
setTimeout( function() {
data_set[CCC.favorite.storage_key()] = localStorage.getItem(CCC.favorite.storage_key()); // ローカルストレージから指定したキーの値を再取得
data_set['looplength'] = null;
ccc_my_favorite_list_ajax(); // お気に入りの投稿をリスト表示するためのAjax関数を呼び出し
},600);
} /*
});
} //endfunction
`
I think the reload has to come straight after the data_set storage / local storage code so it actually removes it?
Regards,
Paul
Hi, Paul ( @create-28 )
Thanks for your reply.
I just tried this customization again in my environment and it worked. No timeout was needed.
I just added “window.location.reload();” just to line 95.
And every time I press the delete icon, it reloads, and the favorites count is correct.
The timing to update local storage or MySQL works right after the delete icon is pressed, so I’m thinking it’s being processed before the reload.
Regards,
Takashi
Thats strange, it’s still there when I add that code, anyway i’ve tried things a different way now where I dont need the page to reload.
Im actually Jquery code to grab the favourite link titles from the page and add them to hide field values in your contact form 7 plugin. So the list of favourites is populated into the form hidden fields.
Thanks for your help though. Not sure why it doesnt update the local storage for me. Instead of reloading page on removal i’ve made a button which opens the form and pulls in the updated favourites list into the form hidden fields.
Regards,
Paul
Hi, Paul ( @create-28 )
Thank you for thinking of another way.
It’s wonderful.
Regards,
Takashi
Hello,
In case someone else would came here looking for a solution, then i figured it out in this way. First off all open the file “/assets/list.js“ and comment out the line 43:
43 /*alert('error');*/
Then add the following code between lines 94 and 95:
setTimeout(function(){ window.location.reload(); }, 3000);
Ultimately, it will look like this:
94 $('#'+ count_post).children('.number').text(list_post_num);
95 setTimeout(function(){ window.location.reload(); }, 3000); //Add this
96 if( Number( list_post_num ) < 1 ) {
Regards,
L