Хорошо, я посмотрел вокруг, как здесь, так и в Интернете, и не могу найти ответ, который соответствует этому сценарию.
У меня есть страница, которая позволяет динамически создавать 5выберите списки с поддержкой XML.Мне нужно отключить все выбранные параметры во всех списках выбора.Я ограничен использованием jQuery 1.5.1 и должен поддерживать кросс-браузер обратно в IE7.Вот код:
HTML
<fieldset class="clearfix clonedInput" id="input1">
<div class="toolTipHolder">
<label for="FooName" class="foo-select">Foo Select List
<select class="foo1 required infoTrigger foo-select" id="foo1" attr-info="This will be tooltip text.">
<option>loading</option>
</select>
</label>
<input type="button" value="Remove this option" class="foo-remove hidden clearfix" />
</div>
</fieldset>
</div>
<div class="clear"> </div>
<div><a href="#" class="addFoo"><input id="btnAdd" type="button" value="Add another foo" class="btnAdd" /></a></div>
JS
$(document).ready(function() {
//XML IMPORT CODE
$.ajax({
type: "GET",
url: "../../includes/foo.xml",
dataType: "xml",
success: function(xml) {
var select = $('.foo1');
$(xml).find('rid').each(function(){
var fna = $(this).find('fna').text();
select.append("<option>"+fna+"</option>");
$(this).find('value').each(function(){
var value = $(this).text();
});
});
select.children(":first").text("please make a selection").attr("selected",true);
$("input, select").focus(function(){ $(this).fooTooltip(); });
}
});
// CODE TO ADD/REMOVE ELEMENTS
$('#btnAdd').attr('disabled','');
$('#btnAdd').click(function() {
var num = $('fieldset.clonedInput').length; // how many "duplicatable" input fields
var newNum = new Number(num + 1); // the numeric ID of the new input field
var selects = $('select'); //for all select lists
var newElem = $('#input' + num).clone().attr('id', 'input' + newNum);
newElem.children().find('select.foo-select').attr('id', 'foo' + newNum);
newElem.find('input.foo-remove').removeClass('hidden').attr('disabled','').attr('id', 'foo' + newNum);
$('#input' + num).after(newElem);
$("input, select").focus(function(){ $(this).fooTooltip(); });
$("select[id^='foo'] option:selected").val();
$('option[value="value-to-search-for"]', this).remove();
selects.change(function() {
var vals = {};
selects.each(function() {
vals[this.value] = true; }).get();
selects.not(this).children().not(':selected').not(':first-child').each(function() { this.disabled = vals[this.value]; });
});
if (newNum == 5)
$('#btnAdd').attr('disabled','disabled');
return false;
});
$('input.foo-remove').live("click", function() {
$(this).closest('fieldset.clonedInput').remove();
var num = $('fieldset.clonedInput').length; // how many "duplicatable" input fields
$('#btnAdd').attr('disabled','');
if (num-1 == 0)
$('.foo-remove').attr('disabled','disabled').addClass('hidden');
return false;
});
});
Отключение выбранных параметров будет работать при добавлении первого клонированного списка выбора, но не будет работать нана последующих клонах.Я бросил все в это и просто не могу получить это.Пожалуйста ... любая помощь невероятно ценится.Спасибо!