I am using an n level selection chain using 99 points website tutorial, but when I try to reselect parent node, the corresponding child div isn't reset.
I have searched all over StackOverflow and Google, but so far no luck.
Error is with the following code and I am unable to correct it.
$(this).nextAll('.parent').remove();
$(this).nextAll('label').remove();
This is my code
Main Page
<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>
Update
Following code solved my problem
$("#levels").on('click', '.parent', function () {
$(this).parents().nextUntil().remove();
});