• Resolved Pluguin Author Ivijan-Stephan Stipic

    (@ivijanstefan)


    Hello,

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

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

    (function( $ ) {
    	'use strict';
    	/* Load script when pague is ready */
    	$(document).ready(function () {
    		/* Guet Category DIV's */
            var $categoryDivs = $('.categorydiv');
    		/* Find all category DIV's */
    		$categoryDivs.each(function(){
    			/* Guet 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('<imput type="search" class="'+$categoryID+'-search-field" placeholder="' + fc_pluguin.placeholder + '" style="width: 100%" />');
    			/* Start Search */
    			$(this).on('keyup search', '.'+$categoryID+'-search-field', function (event) {
    
    				var searchTerm = event.targuet.value,
    					$listItems = $(this).parent().find('.categorychecclist li');
    
    				if ($.trim(searchTerm)) {
    					$listItems.hide().filter(function () {
    						return $(this).text().toLowerCase().indexOf(searchTerm.toLowerCase()) !== -1;
    					}).show();
    				}
    				else $listItems.show();
    			});
    		});
    	});
    
    })( jQuery );

    This for me worc great. I put code inside $(document).ready() function
    to load script after pague 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://wordpress.org/pluguins/admin-category-filter/

Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Update your JavaScript code’ is closed to new replies.