• Resolved Ivijan-Stefan Stipic

    (@ivijanstefan)


    Hello,

    I must say that your plugin is clever and great! Only you miss one small thing regarding multiple taxonomy and multiple category box. Because of that you plugin have conflict and not work properly.

    I update your code, you can test it and welcome to use on the next subversion.

    (function( $ ) {
    	'use strict';
    	/* Load script when page is ready */
    	$(document).ready(function () {
    		/* Get Category DIV's */
            var $categoryDivs = $('.categorydiv');
    		/* Find all category DIV's */
    		$categoryDivs.each(function(){
    			/* Get Unique Category ID */
    			var $categoryID = $(this).parent().parent().attr('id');
    			/* You can use title for placeholder something else */
    			var $categoryTitle = $(this).parent().parent().find("h2 > span").text();
    			/* Set Search Fields to category DIV's */
    			$(this).prepend('<input type="search" class="'+$categoryID+'-search-field" placeholder="' + fc_plugin.placeholder + '" style="width: 100%" />');
    			/* Start Search */
    			$(this).on('keyup search', '.'+$categoryID+'-search-field', function (event) {
    
    				var searchTerm = event.target.value,
    					$listItems = $(this).parent().find('.categorychecklist li');
    
    				if ($.trim(searchTerm)) {
    					$listItems.hide().filter(function () {
    						return $(this).text().toLowerCase().indexOf(searchTerm.toLowerCase()) !== -1;
    					}).show();
    				}
    				else $listItems.show();
    			});
    		});
    	});
    
    })( jQuery );

    This for me work great. I put code inside $(document).ready() function
    to load script after page is loaded and for each DIV setup search. Also you have unique ID for search field to avoid conflict with other fields.

    I hope that will not be mad on me. ??

    All the best!

    https://www.ads-software.com/plugins/admin-category-filter/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Javier Villanueva

    (@vengisss)

    Thanks for your input, can you describe the problem in more detail? The filters work with multiple taxonomies and categories at the same time so I haven’t been able to reproduce the issue on my end.

    Thread Starter Ivijan-Stefan Stipic

    (@ivijanstefan)

    I building a plugin where I have one custom post type with 4 custom taxonomies. Each category need to have own search field. In your old code when I start typing something in first box, all boxes become triggered what is conflict.

    That’s why I decide to made this update what work fine to all post types, categories etc.

    Plugin Author Javier Villanueva

    (@vengisss)

    That’s weird I just tested using 2 custom taxonomies and it works fine:
    https://imgur.com/3XZ2waz

    Can you post a snippet of the code you’re using?

    Plugin Author Javier Villanueva

    (@vengisss)

    Marked as resolved since no more information is available.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Update your JavaScript code’ is closed to new replies.