|
457 | 457 | return;
|
458 | 458 | }
|
459 | 459 |
|
460 |
| - that.updateSelectAll(); |
461 |
| - that.update(); |
462 |
| - that.updateOptGroupSelect(); |
463 |
| - |
464 | 460 | if (that.options.singleSelect) {
|
465 | 461 | var clickedVal = $(this).val();
|
466 | 462 | that.$allControlItems.filter(function() {
|
467 | 463 | return $(this).val() !== clickedVal;
|
468 | 464 | }).each(function() {
|
469 | 465 | $(this).prop('checked', false);
|
470 | 466 | });
|
471 |
| - that.update(); |
472 | 467 | }
|
473 | 468 |
|
| 469 | + that.updateSelectAll(); |
| 470 | + that.update(); |
| 471 | + that.updateOptGroupSelect(); |
| 472 | + |
474 | 473 | that.options.onClick({
|
475 | 474 | label: $(this).parent().text(),
|
476 | 475 | value: $(this).val(),
|
|
571 | 570 | $span.prop('title', this.getSelects('text'));
|
572 | 571 | }
|
573 | 572 |
|
| 573 | + // trigger change on initial setting unless changeOnInit is set to false |
| 574 | + if (this.options.changeOnInit !== false) { |
| 575 | + this.$el.bind('ms-init-change', function() { |
| 576 | + $(this).trigger('change'); |
| 577 | + }); |
| 578 | + } |
| 579 | + |
574 | 580 | // set selects to select
|
575 |
| - this.$el.val(this.getSelects()).trigger('change'); |
| 581 | + this.$el.val(this.getSelects()).trigger('ms-init-change'); |
576 | 582 |
|
577 | 583 | // add selected class to selected li
|
578 | 584 | this.$drop.find('li').not(this.$noResults).removeClass('selected').attr('hidden', false);
|
|
584 | 590 | });
|
585 | 591 |
|
586 | 592 | // trigger <select> change event
|
587 |
| - if (!isInit && isInit !== undefined) { |
| 593 | + if (!isInit) { |
588 | 594 | this.$el.trigger('change');
|
589 | 595 | }
|
590 | 596 | },
|
|
829 | 835 | position: 'bottom',
|
830 | 836 | keepOpen: false,
|
831 | 837 | animate: 'none', // 'none', 'fade', 'slide'
|
| 838 | + changeOnInit: false, |
832 | 839 | displayValues: false,
|
833 | 840 | delimiter: ', ',
|
834 | 841 | addTitle: false,
|
|
0 commit comments