开发者

Javascript in wicket ModalWindow

I have next situation: I open ModalWindow and show in it several Panels by clicking on button - and I need to attach some JavaScript on viewing concrete Panel. How can I do it?

I tried to add Behavior on my Panel:

add(new AbstractBehavior() {
     开发者_开发百科       private static final long serialVersionUID = 1L;

            @Override
            public void renderHead(IHeaderResponse response) {
                String js = "function myFunction(parameter) {  alert('asdasd1'); }";
                response.renderJavascript(js, null);
                response.renderOnDomReadyJavascript("$(document).ready(function() { alert('test2'); myFunction("+paramsFromWicket+") }); ");
            }
        });

but it doesn't work :(


My bad, I found solution. I had to use AbstractAjaxBehavior

add(new AbstractAjaxBehavior() {
            private static final long serialVersionUID = 1L;
            @Override
            public void onRequest() {
            }
            @Override
            public void renderHead(IHeaderResponse response) {
                String js = "function myFunction(param) { alert('Hello World'); } $(document).ready(function() { myFunction(" paramFromWicket + "); });";
                response.renderOnDomReadyJavascript(js);
            }
        });
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜