开发者

Javascript in wicket ModalWindow

开发者 https://www.devze.com 2023-01-05 07:07 出处:网络
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 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

精彩评论

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