0

My users have a list of friends, they can click a button to remove the friend from their firends list. This is done as per below.

Once this is happened I need to refresh #containerFriendsRequestSent because the contents of it have changed. I cannot use location.reload(true); because there are filters on the page and this will reset them meaning the user would have to reselect the filter option.

I thought I could use something like $( "#containerFriendsRequestSent" ).load but this does not seem to refresh the page?

 $('#containerFriendsRequestSent').append(wrapper);
   wrapper.children('.destroy').click(function() {
   $(".destroy").click(function() {
     item.fetchedObject.set("status", "Deleted");
     $('#containerFriendsRequestSent').load();

     item.fetchedObject.destroy(null, {
       success: function(results) {
       console.log("DELETED");
     },
Code Lღver
  • 15,573
  • 16
  • 56
  • 75
Dano007
  • 1,872
  • 6
  • 29
  • 63

3 Answers3

2

Your .load() method isn't correctly used. You have to give a parameter which specifies, which data has to be loaded. In your case you would like to re-load a special container of your page, so you have to do it like this:

$( "#containerFriendsRequestSent" ).load("YOUR-SITE.html #containerFriendsRequestSent" );

Have a look at the jquery api: http://api.jquery.com/load/

David Hermanns
  • 395
  • 3
  • 12
0

use $('#containerFriendsRequestSent').html(''); to set containerFriendsRequestSent blank,then load again.

Suchit kumar
  • 11,809
  • 3
  • 22
  • 44
0

If the logic of deleting the item server-side is working, why not remove the node with ".remove()"? It will be faster and if they reload the page it will properly fetch the new friend list.

iovis
  • 223
  • 1
  • 9