Hi everybody,

Could somebody provide me please with a simple example to update a 
(bootstrap) progress bar when performing a long lasting function.

I read that maybe the after_build_tx hook is the answer to my questions. 
Just not sure how to use is.

after_build_tx <http://mojolicio.us/perldoc/Mojolicious#toc> 

Emitted right after the transaction is built and before the HTTP request 
gets parsed.

$app->hook(after_build_tx => sub {
  my ($tx, $app) = @_;
  ...});

This is a very powerful hook and should not be used lightly, it makes some 
rather advanced features such as upload *progress bars* possible. Note that 
this hook will not work for embedded applications, because only the host 
application gets to build transactions. (Passed the transaction and 
application object)
I wrote a controller which a refresh function which takes quite a while

sub refresh {
    my $self    = shift;

    $total = $self->modules->nr_of_modules();
    foreach my $environment (@environments) {
        my @modules = $self->modules->modules_in_env($environment);
        foreach my $module (@modules) {
            $self->modules->add_module(environment => $environment, module 
=> $module);
            $done++;
            $progress = int($done / $total)*100;
            $self->render( progress => $progress );
        }
    }
}

And would like to pass the $progress to my template and update the progress 
bar.
 

<div class="progress">
  <div class="progress-bar" role="progressbar" aria-valuenow="<%= $progress =>" 
aria-valuemin="0" aria-valuemax="100" style="width: <%= $progress %>%;">
    <%= $progress %>%
  </div></div>

All help will be very much appreciated.

Thx,
Johan

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.

Reply via email to