Skip to content

Commit

Permalink
Merge pull request #156 from adaosantos/after-init
Browse files Browse the repository at this point in the history
Add AfterInit event
  • Loading branch information
crlcu authored Apr 23, 2018
2 parents f304e24 + 8e8b09f commit 22e1523
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/node_modules
.htaccess
.idea
16 changes: 14 additions & 2 deletions dist/js/multiselect.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ if (typeof jQuery === 'undefined') {

// Initialize events
self.events();
if ( typeof self.callbacks.afterInit == 'function' ) {
self.callbacks.afterInit();
}
},

events: function() {
Expand Down Expand Up @@ -223,7 +226,7 @@ if (typeof jQuery === 'undefined') {
self.$left.on('keypress', function(e) {
if (e.keyCode === 13) {
e.preventDefault();

var $options = self.$left.find('option:selected');

if ( $options.length ) {
Expand Down Expand Up @@ -445,7 +448,7 @@ if (typeof jQuery === 'undefined') {
if (!$destinationGroup.length) {
$destinationGroup = $sourceGroup.clone(true);
$destinationGroup.empty();

$destination.move($destinationGroup);
}

Expand Down Expand Up @@ -559,6 +562,15 @@ if (typeof jQuery === 'undefined') {
});
},

/** will be executed after initialize plugin
*
* @method afterInit
*
* @default true
* @return {boolean}
**/
afterInit: function(){ return true; },

/** will be executed each time before moving option[s] to right
*
* IMPORTANT : this method must return boolean value
Expand Down
Loading

0 comments on commit 22e1523

Please sign in to comment.