Trigger Mixitup Filters OnLoad

你说的曾经没有我的故事 提交于 2019-12-13 00:50:53

问题


I'm using the Mixitup (https://mixitup.kunkalabs.com) utility on an ExpressionEngine site. The page is a listing of real estate properties, and the Mixitup filter is to narrow down those properties by region, features, etc.

I want to be able to pass some values via url_segment to trigger the filters. So, for example, if a user clicks the listings from a map divided into various markets, they'll see only the properties in those markets first, as if they had selected it from the main page.

For example, the default view is this:

If they click on Central Indiana, the other regions go away, and a submarket menu opens:

If they further click on South, only the properties in that submarket are displayed. At any time, they can deselect those options, and the hidden properties are revealed.

What I want to do is have the ability for users to visit that page with some options already selected:

I tried using a javascript to click the elements, after all other calls were made:

<script>
     $(document).ready(function(e){
          setTimeout(function() {
               $("li.central-indiana").click();
          },10);
     });
</script>

That expanded the menus, but didn't filter the properties (or apply the "active" class, but that's not really the problem).

I also tried using Mixitup's showOnLoad function at the end of the page, and also with a delay timer:

<script type="text/javascript">
    $("document").ready(function() {
        setTimeout(function() {
             $('#filter').mixitup(
                {'showOnLoad': 'central-indiana'}
             ); 
        },10);   
    });
</script>

That momentarily filtered the properties, but then mixitup reset itself, and displayed them all. It also did not expand the menus or apply the "active" class.

What am I missing here?

Thanks,

ty


回答1:


You need to set something to be filtered on load, like this:

$(function() {
    $('#filter').mixItUp({
        load: {
            filter: '.central-indiana'
        }
    });
});


来源:https://stackoverflow.com/questions/27806595/trigger-mixitup-filters-onload

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!