Answer the question
In order to leave comments, you need to log in
I add news without reloading the page, + photo, how not to shove all the code that needs to be updated into js without reloading?
Hello.
Perhaps the title is stupid) but I thought how to form it correctly.
I add news without reloading the page, via ajax, and also add a photo to the news without reloading, but in order for the photo to appear, shove the photo output code into js, through which ajax passes.
My code is like this:
<div id="photoBox">
<? if (!empty($data['images'])) : ?>
<div id="product_images">
<? foreach ($data['images'] as $i => $image) : ?>
<div class="fotoadmin" data-id="<?= $image->id ?>">
<div class="fotoadminnn">
<a href="/media/uploads/prozhivanie/<?php echo $image->image ?>" target="_blank">
<img src="/media/uploads/prozhivanie/small/small-<?php echo $image->image ?>" width="150px">
</a>
<br>
<a href="/admin/prozhivanie/delimg/<?php echo $image->id ?>">Удалить</a>
<? if ($image->id != $data['image_id']): ?>
| <a href="/admin/prozhivanie/mainimg/<?php echo $image->id ?>">Главная</a>
<? else: ?>
| <b>Главная</b>
<? endif ?>
</div>
</div>
<? endforeach ?>
<input type="hidden" name="imagepos" value="" />
</div>
<a name="img"></a>
<? endif ?>
</div>
if (d.image_is) {
$('#photoBox').append('<div class="fotoadmin"><div class="fotoadminnn"><a href="/media/uploads/prozhivanie/' + d.image.filename + '" target="_blank"><img src="/media/uploads/prozhivanie/small/small-' + d.image.filename + '" width="150px"></a><br><a href="/admin/prozhivanie/delimg/' + d.image.id + '">Удалить</a> | <a href="/admin/prozhivanie/mainimg/' + d.image.id + '">Главная</a></div></div>');
}
<? if ($image->id != $data['image_id']): ?>
| <a href="/admin/prozhivanie/mainimg/<?php echo $image->id ?>">Главная</a>
<? else: ?>
| <b>Главная</b>
<? endif ?>
if (d.image_is) {
$('#photoBox').append('<div class="fotoadmin"><div class="fotoadminnn"><a href="/media/uploads/prozhivanie/' + d.image.filename + '" target="_blank"><img src="/media/uploads/prozhivanie/small/small-' + d.image.filename + '" width="150px"></a><br><a href="/admin/prozhivanie/delimg/' + d.image.id + '">Удалить</a> | <a href="/admin/prozhivanie/mainimg/' + d.image.id + '">Главная</a></div></div>');
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question