How to auto load-more for very large fieldset?

Support General How to auto load-more for very large fieldset?Resolved

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #7759
    WebTrooperWebTrooper
    Participant

    Hi MetaBox folks,

    I'm fairly new to MB and wondering if the project I have in mind can be done only with MB or if it would require more advanced programming skills.

    The project would work similar to WordPress' Theme selection page, but instead of selecting a theme, the user would select a background image. I'm thinking to use image_select fields to display thumbnails of the available background images, each of which could be tagged with, for example, colors, style, light or dark, etc.. The image_select fields would then be searchable and/or sortable according to their tags.

    There will be a lot of them, possibly several hundred or more. Thus, I would need the fields to be paginated or, even better, to auto load-more, like WordPress' Themes page does.

    Is this something I can accomplish using only MB without any custom programming? If so, how would I handle the pagination and/or load more, and how would I handle the search (or sort by tag) functionality?

    Thanks

    #7766
    Anh TranAnh Tran
    Keymaster

    Hi,

    For your needs, the image_select field seems to be the suitable field type. However, it doesn't have the pagination or search feature. To do that, I think you need to write a custom code using a filter library like ListJS (there are probably more libraries).

    You can hook to rwmb_enqueue_scripts action to enqueue your JS like this:

    add_action( 'rwmb_enqueue_scripts', function() {
        wp_enqueue_style( 'listjs', 'URL here' );
        wp_enqueue_script( 'listjs', 'URL here' );
        wp_enqueue_script( 'your-js', 'URL here' );
    } );

    And in your JS file, you can write the JS that does the filtering or searching.

    #7768
    WebTrooperWebTrooper
    Participant

    Thank you for the quick reply. This looks like something I can handle. I see that ListJS documentation includes instructions on using a pagination plugin, so all the better. Have a great day!

Viewing 3 posts - 1 through 3 (of 3 total)
  • The topic ‘How to auto load-more for very large fieldset?’ is closed to new replies.