0

This is probably an easy question, but I can't find an answer anywhere or get it to work.

I'm using http://silviomoreto.github.io/bootstrap-select/ plugin.

How can I fire an event when product items select all/deselect all? I have tried with jquery click and change events like this:

$(document).on('click','#productCategory', function(event) {
    alert("test");
});

This is my Select list:

<select id="productCategory" multiple data-actions-box="true">
    <option>Laptop</option>
    <option>Tablet</option>
    <option>Computer</option>
</select>
freedomn-m
  • 27,664
  • 8
  • 35
  • 57
Emdadul Huq
  • 45
  • 1
  • 3
  • 8

3 Answers3

1

You can refer here: http://silviomoreto.github.io/bootstrap-select/options/#events

$('#productCategory').on('changed.bs.select', function (e) {
  // do something...
});
Akivamu
  • 550
  • 5
  • 17
0
$(document).ready(function(){
    $("#productCategory").click(function(){
        alert("test");
    });

Try this code!

Thala
  • 21
  • 5
0

don't really understand your question. but you want something like this ?

Let me know

$('#productCategory').selectpicker({
  style: 'btn-info',
  size: 4
});
$(".bs-select-all").on('click', function() {
    alert("ALL SELECTED");
});
$(".bs-deselect-all").on('click', function() {
    alert("ALL DESELECTED");
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js">
</script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.11.2/css/bootstrap-select.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.11.2/js/bootstrap-select.min.js"></script>
<select id="productCategory" multiple data-actions-box="true">
    <option>Laptop</option>
    <option>Tablet</option>
    <option>Computer</option>
</select>
Mihai T
  • 17,254
  • 2
  • 23
  • 32