Skip to content
Advertisement

Wicket Ajax works in Firefox and IE but not Chrome and Safari

I’m using Wicket 7.6 and I have some code like this

yearGroupDdl.addToComponent(new AjaxXSRFFormComponentUpdatingBehavior("change", token) {
            @Override
            protected void onUpdate(AjaxRequestTarget target) {
                selectedYearGroup = yearGroupDdl.getComponent().getModelObject();
                filter.setYearGroup(selectedYearGroup);
                target.add(content);
            }
        });

So this code works fine in Firefox and in IE and I see requests in Dev Tools. But when I’m using Chrome and Safari code doesn’t work and there is no even ajax request in Dev Tools, just nothing happens and OnUpdate doesn’t trigger. In Dev Tools in Chrome I have error

Uncaught TypeError: $(...).tooltip is not a function
    at HTMLDocument.<anonymous> (survey_view;jsessionid=FBCB6EED4CCEB02479F1B60D16E3539C?1&entityId=ac4c2a81-9887-4324-a8cf-e463c781475f:48)
    at i (jquery-1.12.4-ver-8195A8C8C12FE76B1AF13FF30D4EC630.js:2)
    at Object.fireWith [as resolveWith] (jquery-1.12.4-ver-8195A8C8C12FE76B1AF13FF30D4EC630.js:2)
    at Function.ready (jquery-1.12.4-ver-8195A8C8C12FE76B1AF13FF30D4EC630.js:2)
    at HTMLDocument.K (jquery-1.12.4-ver-8195A8C8C12FE76B1AF13FF30D4EC630.js:2)

There is no such an error in IE and Firefox console btw. Also there are no tooltips at this page. So, how can i make this works in Chrome? Maybe are there some ajax problems connected with Chrome? I’m using Chrome 85.0.4183.102

Advertisement

Answer

If there is a JavaScript error then everything after the error is not executed.

$('#someElement').tooltip();                            // 1
$('#anotherElement').on('change', function() {...});    // 2

If there is an error at (1) then (2) won’t be executed at all and thus changing the value of #anotherElement won’t trigger the event listener. I.e. Wicket won’t know that the value has changed and won’t make an Ajax call to the server to notify it.

As you said tooltip() is throwing an error because the (Bootstrap ?!) library is not added to the current page. Add it temporarily to see whether this fixes the issue with the dropdown element (and Ajax). Once you do this you can put a breakpoint in tooltip() and investigate why it is being called at all.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement