You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "ASF subversion and git services (JIRA)" <ji...@apache.org> on 2017/12/30 22:10:00 UTC

[jira] [Commented] (WICKET-6489) Exception when "identifier|code" javascript is not start on PrependJavaScript

    [ https://issues.apache.org/jira/browse/WICKET-6489?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16306976#comment-16306976 ] 

ASF subversion and git services commented on WICKET-6489:
---------------------------------------------------------

Commit bce8b05bcf34027ea11ac2db0f0acecf4d317939 in wicket's branch refs/heads/wicket-7.x from [~mgrigorov]
[ https://git-wip-us.apache.org/repos/asf?p=wicket.git;h=bce8b05 ]

WICKET-6489 Exception when "identifier|code" javascript is not start on PrependJavaScript


> Exception when "identifier|code" javascript is not start on PrependJavaScript
> -----------------------------------------------------------------------------
>
>                 Key: WICKET-6489
>                 URL: https://issues.apache.org/jira/browse/WICKET-6489
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 7.9.0
>         Environment: Windows 7 x64
>            Reporter: Duto
>            Priority: Trivial
>
> I use the functionnality of prependJavaScript to replace a composant with animation, but I have I a problem when I have two functions (on difference composants), one with normal syntax like this :
> {code:java}
> target.prependJavaScript("$('" + c.getMarkupId() + "').selectpicker('destroy')");
> {code}
> and I other one with special syntax for animation :
> {code:java}
> target.prependJavaScript(String.format("notify|var c=$('#%s.collapse');if(c.length){c.on('hidden.bs.collapse',function(){notify();});c.collapse('hide');}else{notify();}", c.getMarkupId()));
> {code}
> I get a error when wicket evaluate the javascript :
> {code:java}
> ERROR: Wicket.Ajax.Call.processEvaluation: Exception evaluating javascript: SyntaxError: expected expression, got keyword 'var', text: (function(){$('#var1').selectpicker('destroy');})();(function(){notify|var c=$('#var2.collapse');if(c.length){c.on('hidden.bs.collapse',function(){notify();});c.collapse('hide');}else{notify();}})();
> {code}
> The problem is that the regexp "scriptWithIdentifierR" tests that the javascript is in form of *start with* "identifier|code" or my javascript don't start with "identifier|code" because is :
> {code:javascript}
> (function(){$('#var1').selectpicker('destroy');})();(function(){notify|var c=$('#var2.collapse');if(c.length){c.on('hidden.bs.collapse',function(){notify();});c.collapse('hide');}else{notify();}})();
> {code}
> There is 2 functions : the first is a normal function but the second is "identifier|code" function.
> If I change the var "scriptWithIdentifierR" (https://tinyurl.com/y8r24b5m) to :
> {code:Java}
> new RegExp("\\(function\\(\\)\\{([a-zA-Z_]\\w*)\\|((.|\\n)*)?\\}\\)\\(\\);$");
> {code}
> without the ^ of the first caractere that work nicely.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)