Commit c23484dd authored by David Stutz's avatar David Stutz

Merge pull request #600 from Kichikahunov/master

Added new event. Trigger when initialized. Fixing #543.
parents ccf0758b 0de81032
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
"name": "bootstrap-multiselect", "name": "bootstrap-multiselect",
"description": "Twitter Bootstrap plugin to make selects user friendly.", "description": "Twitter Bootstrap plugin to make selects user friendly.",
"homepage": "http://davidstutz.github.io/bootstrap-multiselect/", "homepage": "http://davidstutz.github.io/bootstrap-multiselect/",
"version": "0.9.13", "version": "0.9.14",
"keywords": [ "keywords": [
"js", "js",
"css", "css",
......
...@@ -151,7 +151,7 @@ ...@@ -151,7 +151,7 @@
this.originalOptions = this.$select.clone()[0].options; this.originalOptions = this.$select.clone()[0].options;
this.query = ''; this.query = '';
this.searchTimeout = null; this.searchTimeout = null;
this.lastToggledInput = null this.lastToggledInput = null;
this.options.multiple = this.$select.attr('multiple') === "multiple"; this.options.multiple = this.$select.attr('multiple') === "multiple";
this.options.onChange = $.proxy(this.options.onChange, this); this.options.onChange = $.proxy(this.options.onChange, this);
...@@ -159,6 +159,7 @@ ...@@ -159,6 +159,7 @@
this.options.onDropdownHide = $.proxy(this.options.onDropdownHide, this); this.options.onDropdownHide = $.proxy(this.options.onDropdownHide, this);
this.options.onDropdownShown = $.proxy(this.options.onDropdownShown, this); this.options.onDropdownShown = $.proxy(this.options.onDropdownShown, this);
this.options.onDropdownHidden = $.proxy(this.options.onDropdownHidden, this); this.options.onDropdownHidden = $.proxy(this.options.onDropdownHidden, this);
this.options.onInitialized = $.proxy(this.options.onInitialized, this);
// Build select all if enabled. // Build select all if enabled.
this.buildContainer(); this.buildContainer();
...@@ -176,6 +177,8 @@ ...@@ -176,6 +177,8 @@
} }
this.$select.hide().after(this.$container); this.$select.hide().after(this.$container);
this.options.onInitialized(this.$select, this.$container);
}; };
Multiselect.prototype = { Multiselect.prototype = {
...@@ -309,6 +312,15 @@ ...@@ -309,6 +312,15 @@
*/ */
onSelectAll: function() { onSelectAll: function() {
},
/**
* Triggered after initializing.
*
* @param {jQuery} $select
* @param {jQuery} $container
*/
onInitialized: function($select, $container) {
}, },
enableHTML: false, enableHTML: false,
buttonClass: 'btn btn-default', buttonClass: 'btn btn-default',
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
<script type="text/javascript" src="lib/jasmine-2.0.2/boot.js"></script> <script type="text/javascript" src="lib/jasmine-2.0.2/boot.js"></script>
<script type="text/javascript" src="../docs/js/jquery-2.1.3.min.js"></script> <script type="text/javascript" src="../docs/js/jquery-2.1.3.min.js"></script>
<script type="text/javascript" src="../docs/js/bootstrap-3.2.0.min.js"></script> <script type="text/javascript" src="../docs/js/bootstrap-3.3.2.min.js"></script>
<script type="text/javascript" src="../dist/js/bootstrap-multiselect.js"></script> <script type="text/javascript" src="../dist/js/bootstrap-multiselect.js"></script>
<script type="text/javascript" src="spec/bootstrap-multiselect.js"></script> <script type="text/javascript" src="spec/bootstrap-multiselect.js"></script>
......
describe('Bootstrap Multiselect "Core".', function() { describe('Bootstrap Multiselect "Core".', function() {
var onInitialized = false;
beforeEach(function() { beforeEach(function() {
var $select = $('<select id="multiselect" multiple="multiple"></select>'); var $select = $('<select id="multiselect" multiple="multiple"></select>');
...@@ -15,7 +17,10 @@ describe('Bootstrap Multiselect "Core".', function() { ...@@ -15,7 +17,10 @@ describe('Bootstrap Multiselect "Core".', function() {
$('body').append($select); $('body').append($select);
$select.multiselect({ $select.multiselect({
buttonContainer: '<div id="multiselect-container"></div>' buttonContainer: '<div id="multiselect-container"></div>',
onInitialized: function($select) {
onInitialized = true;
}
}); });
}); });
...@@ -197,7 +202,11 @@ describe('Bootstrap Multiselect "Core".', function() { ...@@ -197,7 +202,11 @@ describe('Bootstrap Multiselect "Core".', function() {
expect($('#multiselect-container input[value="10"]').prop('checked')).toBe(false); expect($('#multiselect-container input[value="10"]').prop('checked')).toBe(false);
expect($('#multiselect option[value="10"]').prop('selected')).toBe(false); expect($('#multiselect option[value="10"]').prop('selected')).toBe(false);
}); });
it('Should trigger onInitialized.', function() {
expect(onInitialized).toBe(true);
});
afterEach(function() { afterEach(function() {
$('#multiselect').multiselect('destroy'); $('#multiselect').multiselect('destroy');
$('#multiselect').remove(); $('#multiselect').remove();
......
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