Home > Enterprise >  Ajax call on activeadmin filters
Ajax call on activeadmin filters

Time:06-30

I have a active admin filter "Tags" that contain all tags of users. Tags are loading in a collection.

The problem is what if we have thousands of tags? The page will take a lot of time to load all of them and them filter through them.

I wanted to make it dynamic through an AJAX call but I cannot find any resource related to this.

This is active admin filter

"filter :tags , label: 'Tags' , as: :select, collection: proc{ ActsAsTaggableOn::Tag.order(id: :asc).uniq.pluck(:name, :id)}"

CodePudding user response:

This is a popular problem. Therefore, there is a popular solution.

gem activeadmin_addons (search-select-filter)

CodePudding user response:

The question is a bit unclear, but from what I understood you want help on deciding whether you should load something dynamically or not.

I personally think that loading it through Ajax would be a good idea as this will save loading time. To do this you can just use jQuery Ajax as per below.

$.ajax({
  method: "POST",
  url: "file.php",
  data: { data:{/* data */} }
})
  .done(function( msg ) {
    alert( "Data Saved: "   msg );
  });

Source: jQuery Ajax

I hope this helps!

  • Related