Update your JavaScript code
-
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!
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.