我有几个下拉选项,还有一个连接到它的重置按钮。我遇到的问题是当我在下拉菜单中选择几个选项,然后点击重置时,所有其他下拉菜单都会丢失它们的值...我不太熟悉jquery / javascript等但是希望有一些洞察数据为何仅在此实例中丢失
//-------------------
var changeEvent = 0;
var lastSeq = 0;
$scope.change = function(oldValue){
// processed = [];
changeEvent = 1;
if( oldValue != null && oldValue.length==0 ){ /* we have an un-select */
if( K.findAllSelected().size() == 0 ){
$( '.selectpicker option' ).show();
$( '.selectpicker' ).selectpicker( 'refresh' );
changeEvent = 0;
} else {
changeEvent = 2;
}
console.log( " unselect " );
}
lastSeq = this.item_query;
Query.setFirstSelection( lastSeq );
Query.setSelectionText();
};
$('body').click(function(e) {
if ( changeEvent===0 ||
$(e.target).closest('.btn-group').length !== 0) {
return;
}
var methDate = new Date();
var currentVisible = K.getVisibleArray( lastSeq );
K.hideAll();
Query.reinventSelected( lastSeq, changeEvent );
K.showSelected();
K.showThisArraySeq( lastSeq, currentVisible );
changeEvent = 0;
Query.setSelectionText();
$( '.selectpicker' ).selectpicker( 'refresh' );
var endDate = new Date();
console.log("change():" + (endDate - methDate)/1000 +" s");
});
$scope.reset = function(){
$( '.selectpicker' ).selectpicker( 'deselectAll' );
$( '.selectpicker' ).selectpicker( 'show' );
$( '.selectpicker' ).selectpicker( 'refresh' );
$( 'select[id^=query_select]' ).children().end().find( 'option' ).show();
$( 'select[id^=query_select]' ).selectpicker( 'refresh' );
$( '.input-daterange input' ).each(function() { $(this).datepicker("clearDates"); });
$rootScope.$broadcast('sql', K.selectedFields());
Query.setFirstSelection(0);
Query.setSelectionText();
}