0

我正在使用新媒体活动的可过滤投资组合脚本(http://www.newmediacampaigns.com/page/a-jquery-plugin-to-create-an-interactive-filterable-portfolio-like-ours),效果很好在无序列表中使用普通链接时。不过,我想在选择框中提供选项。谁能指出我正确的方向?

编辑:我想通过从这样的选择框中选择选项来使用过滤器

<select id="someid">
  <option selected value="#All">All</option>            
  <option value="#Design">Design</option>      
  <option value="#Political">Political</option>
  <option value="#Business">Business</option>
</select> 
4

1 回答 1

1

changeselect. 在这个处理程序中,您需要调用与单击链接相同的例程!

但是:changeraise -event 取决于浏览器。一个人可能会立即调用它,其他人当你模糊时!

将这个想法与可过滤的文档结合起来:

$(document).ready(function(){
 $('portfolio-list').filterable();
 $('#linkID').click(function(){
  $('portfolio-list').trigger('filter', [ '#jquery' ]);
 });
});

例如

var myFilterable = $('#myFilterable').filterable();
var mySelect = $('#mySelect');
mySelect.change(function() {
    var index = mySelect[0].selectedIndex;
    var element = mySelect[0].options[index];
    var tag = $(element).attr('value'); // jQuery variant
    //var tag = element.value; // html variant
    //var tag = $(element).val(); // should work either!
    // TODO: create an array with the variable value
    myFilterable.trigger('filter', /* array of tag(s) you want to show*/);
});
于 2010-02-04T10:05:27.603 回答