Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 1e6fdf48

Von Moritz Bunkus vor mehr als 10 Jahren hinzugefügt

  • ID 1e6fdf4876cf4b5ee1eedd4ca6ad2888fec8a152
  • Vorgänger 37ff0a6b
  • Nachfolger 293c7b64

ClientJS: Controller-Instanz zum Rendern auch bei ->new setzen können

Unterschiede anzeigen:

SL/ClientJS.pm
9 9

  
10 10
use Rose::Object::MakeMethods::Generic
11 11
(
12
  scalar                  => [ qw(controller) ],
12 13
  'scalar --get_set_init' => [ qw(_actions _flash _error) ],
13 14
);
14 15

  
......
188 189

  
189 190
sub render {
190 191
  my ($self, $controller) = @_;
192
  $controller ||= $self->controller;
191 193
  $self->reinit_widgets if $::request->presenter->need_reinit_widgets;
192 194
  return $controller->render(\$self->to_json, { type => 'json' });
193 195
}
......
269 271
    my ($self) = @_;
270 272

  
271 273
    # Create a new client-side JS object and do stuff with it!
272
    my $js = SL::ClientJS->new;
274
    my $js = SL::ClientJS->new(controller => $self);
273 275

  
274 276
    # Show some element on the page:
275 277
    $js->show('#usually_hidden');
......
295 297

  
296 298
    # Rendering can also be chained, e.g.
297 299
    $js->html('#selector', $html)
298
       ->render($self);
300
       ->render;
299 301
  }
300 302

  
301 303
=head1 OVERVIEW
......
345 347
Returns the actions gathered so far as a JSON string ready to be sent
346 348
to the client.
347 349

  
348
=item C<render $controller>
350
=item C<render [$controller]>
349 351

  
350 352
Renders C<$self> via the controller. Useful for chaining. Equivalent
351 353
to the following:
352 354

  
353 355
  $controller->render(\$self->to_json, { type => 'json' });
354 356

  
357
The controller instance to use can be set during object creation (see
358
synopsis) or as an argument to C<render>.
359

  
355 360
=item C<dialog>
356 361

  
357 362
Tells C<$self> that the next action is to be called on a jQuery UI

Auch abrufbar als: Unified diff