# ## other stuff ##
redirect_to => 1, # window.location.href = <TARGET>
+
+ reinit_widgets => 0, # kivi.reinit_widgets()
);
sub AUTOLOAD {
sub render {
my ($self, $controller) = @_;
+ $self->reinit_widgets if $::request->presenter->need_reinit_widgets;
return $controller->render(\$self->to_json, { type => 'json' });
}
use SL::Presenter::Text;
use SL::Presenter::Tag;
+use Rose::Object::MakeMethods::Generic (
+ scalar => [ qw(need_reinit_widgets) ],
+);
+
sub get {
return $::request->presenter;
}
join('', map { $params{$_} ? $self->input_tag("", delete $params{$_}, id => "${id}_${_}", type => 'hidden') : '' } qw(column type unit convertible_unit)) .
$self->input_tag("", (ref $value && $value->can('description')) ? $value->description : '', id => "${id}_name", %params);
+ $::request->presenter->need_reinit_widgets($id);
+
$self->html_tag('span', $ret, class => 'part_picker');
}
push @classes, delete($params{class}) if $params{class};
my %class = @classes ? (class => join(' ', @classes)) : ();
+ $::request->presenter->need_reinit_widgets($params{id});
+
return $self->input_tag(
$name, blessed($value) ? $value->to_lxoffice : $value,
size => 11,
// ## other stuff ##
else if (action[0] == 'redirect_to') window.location.href = action[1];
+ else if (action[0] == 'reinit_widgets') kivi.reinit_widgets();
else console.log('Unknown action: ' + action[0]);
ns.setupLocale = function(locale) {
ns._locale = locale;
};
+
+ ns.reinit_widgets = function() {
+ $('.datepicker').each(function() {
+ $(this).datepicker();
+ });
+
+ if (ns.PartPicker)
+ $('input.part_autocomplete').each(function(idx, elt){
+ kivi.PartPicker($(elt));
+ });
+ };
});
kivi = namespace('kivi');