Prilis dlouhy redrawControl() pres AJAX
- blueticket
- Člen | 41
Zdravim Vas, nevim jestli je to normalni, ale muj redraw control trva prilis dlouhu (na core i5 cca 400–500ms) a nevim jestli delam neco spatne.
v sablone mam nadefinovanej ul a v nem foreach:
{snippet bill}
<ul class="bill">
{var $total = 0}
{var $subtotal = 0}
{var $discount = 0}
{foreach $items as $item}
{var $subtotal = $subtotal + $item->base_unit_price_w_tax*$item->quantity}
{var $discount = $discount + $item->discount_value_w_tax*$item->quantity}
<li>
<div class="col-xs-2 padding-side-0">
<span class="item_registration_code">{$item->product_code}</span>
<span class="vat_info">{_"DPH"}: {$item->product_tax}%</span>
</div>
<div class="col-xs-5 padding-side-0">
<span class="item_name">{$item->product_name}</span>
</div>
<div class="col-xs-4 padding-side-2">
<span class="item_price">{$item->base_unit_price_w_tax*$item->quantity|number:2} {!_"€"}</span>
<span class="item_info_price">{$item->quantity|number:3} {$item->product_unit} x {$item->base_unit_price_w_tax|number:2} {!_"€"}</span>
</div>
<a class="edit_item col-xs-1 padding-side-0" data-toggle="modal" data-target="#ModalEditItem">
<i class="ion-compose"></i>
</a>
{if strlen($item->note) > 0}
<span class="item_note">
<i class="ion-information-circled"></i>
{$item->note}
</span>
{/if}
</li>
{/foreach}
{var $total = $subtotal - $discount}
</ul>
{/snippet}
a nasledne pak v presenteru:
public function render() {
$items_count = $this->database->table("sma_document_items_tmp")->where("cart_nr=?", $this->cart_nr)->count();
if ($items_count > 0) {
$items = $this->database->table("sma_document_items_tmp")->where("cart_nr=?", $this->cart_nr)->order("id DESC")->fetchAll();
$this->template->items = $items;
}
$this->template->items_count = $items_count;
$this->template->setTranslator($this->getPresenter()->translator);
$this->template->setFile(__DIR__ . "/bill.latte");
$this->template->render();
}
vyuzivam nette.ajax.js a kdyz volam metodu redrawControl() tak mi nabihaji brutalni casy. 400 – 1500ms na redraw (dle procesoru) i kdyz vypnu debug a zapnu cache pro latte.
Samotna metoda, kdyz nezavolam redrawControl(), ale terminate() na jeji
konci, trva cca 20–50ms.
Take pri debugu pres firebug mi vraci pouze snippet s ul-li a nic vice.
Nesetkali ste se nekdo s necim podobnym? Nevite me navest na reseni?
Diky moc predem!
- AdamVyborny
- Člen | 36
Jak dlouho trvá samotné načtení stránky? Jde o to, že se znova projede životní cyklus presenteru při redraw(). Občas je lepší se vykašlat na nějaký snippety a řešit to klasicky AJAXem plus .append() / .html() nebo podobně…