99 ポイントの Web サイト チュートリアルを使用してn レベルの選択チェーンを使用して いますが、親ノードを再選択しようとすると、対応する子 div がリセットされません。
StackOverflow と Google を検索しましたが、今のところうまくいきません。
エラーは次のコードにあり、修正できません。
$(this).nextAll('.parent').remove();
$(this).nextAll('label').remove();
これは私のコードです
メインページ
<script type="text/javascript">
$('.parent').livequery('change', function() {
$(this).nextAll('.parent').remove();
$(this).nextAll('label').remove();
$.post("/dashboard/details/show_levels/", {
parent_id: $(this).val(),
}, function(response){
setTimeout("finishAjax('levels', '"+escape(response)+"')", 400);
});
return false;
});
})
function finishAjax(id, response){
//alert(unescape(response));
$('#'+id).append(unescape(response));
}
</script>
<div id=levels>
<select id="level" class="parent" multiple="multiple" scroabble="1" name="data[level][]">
<option value="Building & Construction Mat">Building & Construction Mat</option>
<option value="Electronic Components">Electronic Components</option>
<option value="Furniture & Mattresses">Furniture & Mattresses</option>
<option value="Labels">Labels</option>
</select>
</div>
show_levels
<select id="sublevel" class="parent" multiple="multiple" scroabble="1" name="data[sublevel][]">
<option value="Labels">Labels</option>
<option value="Preparation Techniques">Preparation Techniques</option>
<option value="Process Parameters">Process Parameters</option>
</select>
アップデート
次のコードは私の問題を解決しました
$("#levels").on('click', '.parent', function () {
$(this).parents().nextUntil().remove();
});