You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wicket.apache.org by GitBox <gi...@apache.org> on 2020/01/29 05:59:21 UTC
[GitHub] [wicket] andruhon commented on issue #402: WICKET-6731: Inline JS
in SubmitLink
andruhon commented on issue #402: WICKET-6731: Inline JS in SubmitLink
URL: https://github.com/apache/wicket/pull/402#issuecomment-579607334
Sorry for late comment. What if we add something like these to avoid repeated use of Strings concatenation programming?
```
public static void addEventListener(final IHeaderResponse headerResponse, Component component, String event, CharSequence javascript)
{
addEventListener(headerResponse, component, event, "event", javascript, false);
}
public static void addEventListener(final IHeaderResponse headerResponse, Component component, String event, String eventParamName, CharSequence javascript, boolean priority)
{
OnDomReadyHeaderItem item = OnDomReadyHeaderItem.forScript(
String.format(
"var el = document.getElementById('%s'); if(el){el.addEventListener('%s', function(%s){ %s; });}",
component.getMarkupId(),
event,
eventParamName,
javascript
)
);
headerResponse.render(priority ? new PriorityHeaderItem(item) : item);
}
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services