mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-11-14 13:16:28 +08:00
41 lines
1.1 KiB
JavaScript
41 lines
1.1 KiB
JavaScript
|
var previousIndex;
|
||
|
var disabledOptions;
|
||
|
$("select").focus(function() {
|
||
|
previousIndex = $(this)[0].selectedIndex;
|
||
|
}).change(function () {
|
||
|
var currSelect = $(this);
|
||
|
var currIndex = $(currSelect)[0].selectedIndex;
|
||
|
|
||
|
$("select").each(function() {
|
||
|
if (currSelect !== $(this) && currIndex > 0) {
|
||
|
$(this).children().eq(currIndex).attr("disabled", "disabled");
|
||
|
}
|
||
|
|
||
|
$(this).children().eq(previousIndex).removeAttr("disabled");
|
||
|
});
|
||
|
|
||
|
previousIndex = currIndex;
|
||
|
});
|
||
|
|
||
|
// Create import samples ajax
|
||
|
$("form#form-import")
|
||
|
.submit(function(e) {
|
||
|
disabledOptions = $("option[disabled='disabled']");
|
||
|
disabledOptions.removeAttr("disabled");
|
||
|
})
|
||
|
.on("ajax:success", function(ev, data, status) {
|
||
|
// Simply reload page to show flash and updated samples list
|
||
|
location.reload();
|
||
|
})
|
||
|
.on("ajax:error", function(ev, data, status) {
|
||
|
if (_.isUndefined(data.responseJSON.html)) {
|
||
|
// Simply reload page to show flash
|
||
|
location.reload();
|
||
|
} else {
|
||
|
// Re-disable options
|
||
|
disabledOptions.attr("disabled", "disabled");
|
||
|
|
||
|
// Populate the errors container
|
||
|
$("#import-errors-container").html(data.responseJSON.html);
|
||
|
}
|
||
|
});
|