Revision 3ac83c61
Von Moritz Bunkus vor mehr als 11 Jahren hinzugefügt
SL/ClientJS.pm | ||
---|---|---|
103 | 103 |
|
104 | 104 |
# ## other stuff ## |
105 | 105 |
redirect_to => 1, # window.location.href = <TARGET> |
106 |
|
|
107 |
reinit_widgets => 0, # kivi.reinit_widgets() |
|
106 | 108 |
); |
107 | 109 |
|
108 | 110 |
sub AUTOLOAD { |
... | ... | |
168 | 170 |
|
169 | 171 |
sub render { |
170 | 172 |
my ($self, $controller) = @_; |
173 |
$self->reinit_widgets if $::request->presenter->need_reinit_widgets; |
|
171 | 174 |
return $controller->render(\$self->to_json, { type => 'json' }); |
172 | 175 |
} |
173 | 176 |
|
SL/Presenter.pm | ||
---|---|---|
19 | 19 |
use SL::Presenter::Text; |
20 | 20 |
use SL::Presenter::Tag; |
21 | 21 |
|
22 |
use Rose::Object::MakeMethods::Generic ( |
|
23 |
scalar => [ qw(need_reinit_widgets) ], |
|
24 |
); |
|
25 |
|
|
22 | 26 |
sub get { |
23 | 27 |
return $::request->presenter; |
24 | 28 |
} |
SL/Presenter/Part.pm | ||
---|---|---|
18 | 18 |
join('', map { $params{$_} ? $self->input_tag("", delete $params{$_}, id => "${id}_${_}", type => 'hidden') : '' } qw(column type unit convertible_unit)) . |
19 | 19 |
$self->input_tag("", (ref $value && $value->can('description')) ? $value->description : '', id => "${id}_name", %params); |
20 | 20 |
|
21 |
$::request->presenter->need_reinit_widgets($id); |
|
22 |
|
|
21 | 23 |
$self->html_tag('span', $ret, class => 'part_picker'); |
22 | 24 |
} |
23 | 25 |
|
SL/Template/Plugin/L.pm | ||
---|---|---|
226 | 226 |
push @classes, delete($params{class}) if $params{class}; |
227 | 227 |
my %class = @classes ? (class => join(' ', @classes)) : (); |
228 | 228 |
|
229 |
$::request->presenter->need_reinit_widgets($params{id}); |
|
230 |
|
|
229 | 231 |
return $self->input_tag( |
230 | 232 |
$name, blessed($value) ? $value->to_lxoffice : $value, |
231 | 233 |
size => 11, |
js/client_js.js | ||
---|---|---|
119 | 119 |
|
120 | 120 |
// ## other stuff ## |
121 | 121 |
else if (action[0] == 'redirect_to') window.location.href = action[1]; |
122 |
else if (action[0] == 'reinit_widgets') kivi.reinit_widgets(); |
|
122 | 123 |
|
123 | 124 |
else console.log('Unknown action: ' + action[0]); |
124 | 125 |
|
js/kivi.js | ||
---|---|---|
26 | 26 |
ns.setupLocale = function(locale) { |
27 | 27 |
ns._locale = locale; |
28 | 28 |
}; |
29 |
|
|
30 |
ns.reinit_widgets = function() { |
|
31 |
$('.datepicker').each(function() { |
|
32 |
$(this).datepicker(); |
|
33 |
}); |
|
34 |
|
|
35 |
if (ns.PartPicker) |
|
36 |
$('input.part_autocomplete').each(function(idx, elt){ |
|
37 |
kivi.PartPicker($(elt)); |
|
38 |
}); |
|
39 |
}; |
|
29 | 40 |
}); |
30 | 41 |
|
31 | 42 |
kivi = namespace('kivi'); |
Auch abrufbar als: Unified diff
ClientJS: automatisch Date- und Partpicker nach AJAX-Request initialisieren