ok, zrobiłem tak po prostu:
// Skrypt usuwający rozdział
function removeMain(main) {
var catNumber = $(main).data('mainCat');
$('#cat' + catNumber).find('.row').not('.rozdzial:first-child', '#cat' + catNumber + 'main0').remove();
return false;
}
wyrzuca mi wszystkie poza pierwszym. chcialbym zeby jeszcze w pierwszym nie wywalal mi tego (co jest w nawiasie, ale nie dziala)
'#cat' + catNumber + 'main0'
juz nie bede sie bawil bo nie ma czasu na wywalanie ostatniego bo po prostu nei wiem jak to zrobic i tak wywala wszystkie albo zadnego - ale zeby ten pierwszy zestaw zostawil
@EDIT
jeszcze raz przytocze kod dla jasnosci:
<div id="cat<?php echo $i; ?>">
<?php for ($x = 0; $x < $countMains; $x++): ?>
<?php $countLinks = count($c -> catalog[$i] -> main[$x] -> link); ?>
<div class="row rozdzial"> <input class="form-control text-center" type="text" name="mainTitle[]" value="<?php echo $c -> catalog[$i] -> main[$x] -> title; ?>" required />
<input class="form-control text-center" type="text" name="mainPage[]" value="<?php echo $c -> catalog[$i] -> main[$x] -> page; ?>" required />
<button class="btn btn-md text-center btn-delete" style="width: 100%; height: 100%;" data-main-cat="<?php echo $i; ?>" data-main-row="
<?php echo $x; ?>" onclick="return removeMain(this);">
<span class="fa fa-remove icon-md" title="Usuń link"></span></button> <button class="btn btn-md text-center btn-add" style="width: 100%; height: 100%;" data-row-cat="<?php echo $i; ?>" data-row-count="
<?php echo $countMains; ?>" onclick="return addMain(this);">
<span class="fa fa-plus icon-md" title="Dodaj link"></span></button>
<div id="<?php echo 'cat'.$i.'main'.$x; ?>">
<?php for ($y = 0; $y < $countLinks; $y++): ?>
<?php if ($y < 1): ?>
<input class="form-control text-center" type="text" name="linkTitle[]" value="<?php echo $c -> catalog[$i] -> main[$x] -> link[$y] -> title; ?>" required />
<input class="form-control text-center" type="text" name="linkPage[]" value="<?php echo $c -> catalog[$i] -> main[$x] -> link[$y] -> page; ?>" required />
<button class="btn btn-md text-center btn-delete" style="width: 100%; height: 100%;" data-row-cat="<?php echo $i; ?>" data-row-main="
<?php echo $x; ?>" onclick="return removeRow(this);">
<span class="fa fa-remove icon-md" title="Usuń link"></span></button> <button class="btn btn-md text-center btn-add" style="width: 100%; height: 100%;" data-row-cat="<?php echo $i; ?>" data-row-main="
<?php echo $x; ?>" onclick="return addRow(this);">
<span class="fa fa-plus icon-md" title="Dodaj link"></span></button> <?php else: ?>
<div class="row" style="margin-bottom: 3px;"> <input class="form-control text-center" type="text" name="linkTitle[]" value="<?php echo $c -> catalog[$i] -> main[$x] -> link[$y] -> title; ?>" required />
<input class="form-control text-center" type="text" name="linkPage[]" value="<?php echo $c -> catalog[$i] -> main[$x] -> link[$y] -> page; ?>" required />
<?php endif ?>
<?php endfor ?>
<?php endfor ?>
i funkcje
function removeMain(main) {
var catNumber = $(main).data('mainCat');
var mainNumber = $(main).data('mainRow');
$('#cat' + catNumber).find('.row').not('.row:first-child, #cat' + catNumber + 'main0').remove();
return false;
}
która wywala .row ale zostawia wszystkie divy "cat1row0", "cat1row1"... a chce zeby zostawiul tylko cat1row0