У меня есть код jQuery, который переносит все атрибуты с одной стороны панели на другую. Эта кнопка работает как «Добавить все». Следующий код делает это возможным.
Пока что я сделал некоторые изменения, чтобы удовлетворить свои цели. Следующий код, который я пробовал, все еще работает как «Добавить все»
Он продолжает приносить мне все значения из одной таблицы в другую вместо тех, где промышленность = авто.
Это оригинальный код «Добавить все».
this.container.find(".add-all").click(function() {
var options = that.element.find('option').not(":selected");
if (that.availableList.children('li:hidden').length > 1) {
that.availableList.children('li').each(function(i) {
if (jQuery(this).is(":visible")) jQuery(options[i-1]).attr('selected', 'selected');
});
} else {
options.attr('selected', 'selected');
}
that._populateLists(that.element.find('option'));
return false;
});
Это то, что я пробовал до сих пор ...
this.container.find(".add-auto").click(function() {
var options = that.element.find('option').not(":selected");
var elements = $('li').find("[industry]")
if (that.availableList.children('li:hidden').length > 1) {
that.availableList.children('li').each(function(i) {
if (jQuery(this).is(":visible") && jQuery(this).find("[industry = 'auto']")) jQuery(options[i-1]).attr('selected', 'selected');
});
} else {
that.availableList.children('li').each(function (i) {
if (jQuery(this).find("[industry = 'auto']")) jQuery(options[i-1]).attr('selected','selected');
});
}
that._populateLists(that.element.find('option'));
return false;
});