Home Forums WoodMart support forum Sidebar Filter Attributes Collapse Reply To: Sidebar Filter Attributes Collapse

#111536

webresultat
Participant

Hi,
could you please give me a hint what to do with the code to implement the show more button into the widget?

I have found out that the code should be working adding some code to child themes functions.php
Here is the part I added to the functions:

function my_theme_scripts_function() {
wp_enqueue_script( 'myscript', get_stylesheet_directory_uri() . '/js/hide.js');
}
add_action('wp_enqueue_scripts','my_theme_scripts_function');

and then I added a hide.js file into themes js folder using the ID of the widget i want to add the show more :

var limit = 10;
var list = $("#woodmart-woocommerce-layered-nav-14");
var more = 0;

function tricky_hide(){
    var morec = 0;
    $("li", list).each(function(index) {
        if (index >= limit) {
            $(this).hide();      
            morec = index - limit + 1;
        }
    });
    if (!more) more = morec;
    if (more) {
        list.append('<li class="more">' + more + ' more</li>');
        return true;
    }
    return false;
}
if (tricky_hide()) {
    list.live("mouseover", function() {
        $("li", list).each(function(index) {
            $(this).show();
        });
        $("li.more", list).hide();
    });

    list.live("mouseout", function() {
        tricky_hide();
    });
}

but it’s not working yet.
maybe I just made some mistake in the function file?
should it be named “my_theme_scripts_function” or woodmart_scripts_function” for example?

thank for your help