mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-10-06 03:46:39 +08:00
Fix marking of selected option [SCI-819]
This commit is contained in:
parent
e22ff6f8bb
commit
4065be9e4e
2 changed files with 35 additions and 1 deletions
|
@ -780,6 +780,9 @@ function createSampleTypeSelect(data, selected) {
|
||||||
$.each(data, function(i, val) {
|
$.each(data, function(i, val) {
|
||||||
var $option = $('<option></option>')
|
var $option = $('<option></option>')
|
||||||
.attr('value', val.id).text(val.name);
|
.attr('value', val.id).text(val.name);
|
||||||
|
if((i + 1) === selected) {
|
||||||
|
$option.attr('selected', true);
|
||||||
|
}
|
||||||
$selectType.append($option);
|
$selectType.append($option);
|
||||||
});
|
});
|
||||||
return $selectType;
|
return $selectType;
|
||||||
|
@ -806,7 +809,9 @@ function createSampleGroupSelect(data, selected) {
|
||||||
var $option = $('<option></option>')
|
var $option = $('<option></option>')
|
||||||
.attr('value', val.id).text(val.name)
|
.attr('value', val.id).text(val.name)
|
||||||
.attr('data-content', $span.prop('outerHTML') + ' ' + val.name);
|
.attr('data-content', $span.prop('outerHTML') + ' ' + val.name);
|
||||||
|
if((i + 1) === selected) {
|
||||||
|
$option.attr('selected', true);
|
||||||
|
}
|
||||||
$selectGroup.append($option);
|
$selectGroup.append($option);
|
||||||
});
|
});
|
||||||
return $selectGroup;
|
return $selectGroup;
|
||||||
|
|
|
@ -215,3 +215,32 @@ function initPageTutorialSteps(pageFirstStepN, pageLastStepN, nextPagePath,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add redirection links on dropdown elements. You must specify 'href'
|
||||||
|
* attribute yourself, and the dropdown elments which don't have them, will get
|
||||||
|
* '#' by default.
|
||||||
|
* @param {number} selectedIdx Index of element to be selected
|
||||||
|
* @param {string} urlParam URL parameter to pass to the link URLs
|
||||||
|
* @return {Object} This
|
||||||
|
*/
|
||||||
|
$.fn.makeDropdownOptionsLinks = function(selectedIdx, urlParam) {
|
||||||
|
selectedIdx = _.isUndefined(selectedIdx) ? 1 : selectedIdx;
|
||||||
|
|
||||||
|
$(this).change(function() {
|
||||||
|
window.location.href = addParam($(this).find('option:selected')
|
||||||
|
.attr('href'), urlParam);
|
||||||
|
});
|
||||||
|
|
||||||
|
$(this).find('option')
|
||||||
|
.each(function() {
|
||||||
|
if ($(this).is('[href]')) {
|
||||||
|
$(this).addClass('link-look');
|
||||||
|
} else {
|
||||||
|
$(this).attr('href', '#');
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.eq(selectedIdx).attr('selected', true);
|
||||||
|
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue