X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/kivitendo-erp.git/blobdiff_plain/3a94c2e211df64dbcbd2b396a12e4bf1f3cf59aa..35cf7c7029b4aa69eb9d02c7533d1a15aafb118b:/SL/ClientJS.pm diff --git a/SL/ClientJS.pm b/SL/ClientJS.pm index f1c949e5f..335bf8163 100644 --- a/SL/ClientJS.pm +++ b/SL/ClientJS.pm @@ -122,6 +122,8 @@ my %supported_methods = ( scroll_into_view => 1, # $()[0].scrollIntoView() ); +my %trim_target_for = map { ($_ => 1) } qw(insertAfter insertBefore appendTo prependTo); + sub AUTOLOAD { our $AUTOLOAD; @@ -154,6 +156,11 @@ sub action { $args[$idx] = "" . $args[$idx] if ref($args[$idx]) eq 'SL::Presenter::EscapedText'; } + # Trim leading whitespaces for certain jQuery functions that operate + # on HTML code: $("

test

").appendTo('#some-id'). jQuery croaks + # on leading whitespaces, e.g. on $("

test

"). + $args[0] =~ s{^\s+}{} if $trim_target_for{$method}; + push @{ $self->_actions }, [ $method, @args ]; return $self;