Commit 416bf64d authored by David Stutz's avatar David Stutz

Merge pull request #9 from najlepsiwebdesigner/master

2 lines of code added to add support for change event.
parents aca02c24 63368815
...@@ -16,7 +16,9 @@ ...@@ -16,7 +16,9 @@
<body> <body>
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function() { $(document).ready(function() {
$('#example1').multiselect(); $('#example1').multiselect({
onchange:function(el, checked){alert('change event invoked!'); console.log(el, checked)}
});
$('#example2').multiselect(); $('#example2').multiselect();
$('#example3').multiselect({ $('#example3').multiselect({
button: 'btn btn-link' button: 'btn btn-link'
......
...@@ -65,9 +65,12 @@ ...@@ -65,9 +65,12 @@
$(event.target).parents('li').removeClass('active'); $(event.target).parents('li').removeClass('active');
} }
$('option[value="' + $(event.target).val() + '"]', this.select).attr('selected', checked); var $option = $('option[value="' + $(event.target).val() + '"]', this.select);
$option.attr('selected', checked);
$('button', this.container).html(this.options.text($('option:selected', this.select)) + ' <b class="caret"></b>'); $('button', this.container).html(this.options.text($('option:selected', this.select)) + ' <b class="caret"></b>');
this.options.onchange($option, checked);
}, this)); }, this));
$('ul li a', this.container).on('click', function(event) { $('ul li a', this.container).on('click', function(event) {
...@@ -99,6 +102,7 @@ ...@@ -99,6 +102,7 @@
} }
}, },
container: '<div class="btn-group" />', container: '<div class="btn-group" />',
onchange:function(){}
}, },
constructor: Multiselect, constructor: Multiselect,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment