[英]MixItUp not working on Select box (works with button)
I need to filter a MixItUp based on the selection of a dropbox. 我需要根据投递箱的选择来过滤MixItUp。 I have a physical button working, but when I try to change it to a select box my code fails.
我有一个物理按钮在工作,但是当我尝试将其更改为选择框时,我的代码失败。
Here is a functioning button that properly fires the MixItUp filter: 这是一个可以正常启动MixItUp过滤器的功能按钮:
<button class="filter btn red" data-filter=".2" data-parent="#plan_list" href="#2" data-toggle="collapse" onclick="set_plan("test","2")" id="plan-2"><i class="fa fa-tag margin-right-10"></i>test</button>
The function fires on change, but the filter is not being applied. 该函数会在更改时触发,但未应用过滤器。 (I have a custom function that fires, so I know the call is working).
(我有一个自定义函数会触发,因此我知道该调用正在工作)。
My code is based off this codepen: http://codepen.io/patrickkunka/pen/btCim 我的代码基于此Codepen: http ://codepen.io/patrickkunka/pen/btCim
Here is the JS for the change: 这是更改的JS:
$(function(){
var $filterSelect = $('#FilterSelect'),
$container = $('#Container');
$container.mixItUp();
$filterSelect.on('change', function(){
$container.mixItUp('filter', '.'+this.value);
set_plan('test',this.value); //custom function working properly
});
});
In the JS above this.value is the plan_id . 在上面的JS中,this.value是plan_id。 I have to add the '.'+this.value in the code above here so that other functions can work on the clean plan id.
我必须在上面的代码中添加“。” + this.value,以便其他功能可以在干净的计划ID上使用。 I have tested this code and that part works so I know its not the issue.
我已经测试了此代码,并且该部分有效,所以我知道这不是问题。
Here is the code for the select (php): 这是select(php)的代码:
<select id="FilterSelect">
<? foreach ($plans as $plan) {echo '<option value="'.$plan['id'].'">'.$plan['name'].'</option> ';?>
</select>
Can anyone tell me what I missed? 谁能告诉我我错过了什么? The button works, the select does not.
该按钮有效,但选择无效。
I discovered the problem. 我发现了问题。 Its not in the code listed above:
它不在上面列出的代码中:
I was missing the container id for the html categories to be filtered. 我缺少要过滤的html类别的容器ID。
<div class="Container">
should have been: 本来应该:
<div id="Container" >
Stupid simple mistake, I reviewed this code several times and saw it, but in my mind read it as id not class. 愚蠢的简单错误,我多次阅读了这段代码并看到了它,但是在我看来,它是作为id而不是类来读取的。
New question, how do I fix the bugs in my brain????!!! 新问题,如何解决大脑中的错误?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.