0

Wicket AjaxSubmitLink onSubmit is not called after applying appendJavascript which changes the DOM of a page. Sample code is:

add(new ListView("list", someArrayList){
            @Override
            protected void populateItem(final ListItem item) {
                add(new AjaxSubmitLink("link") {
                     @Override
                     public void onClick(AjaxRequestTarget target) {
                         target.appendJavascript("swap('"+this.getMarkupId()+"')");
                     });
})

The JavaScript looks like:

function swap(markupId){
    var one = $('.dashed').first().parent();
    var two = $('#'+markupId).parent();
    var tone = one.clone();
    var ttwo = two.clone();
    one.replaceWith(ttwo);
    two.replaceWith(tone);
}

Any suggestions?

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
falconw
  • 59
  • 5
  • Not really sure, you left a lot of code out (html? hwere is your JS included?). My guess is that you are swapping something with the `markupId` of the AjaxSubmitLink. Try an `alert` with the `id` first or use a debugger to find out what is happening. – Rob Audenaerde May 27 '14 at 07:02

1 Answers1

2

It might be the clone() method causing the problem. According the documentation it does not clone event handlers. Try clone(true);

You could also handle the swap server side and then rerender the list after the swap. That would be the Wicket way to do it.

papkass
  • 1,261
  • 2
  • 14
  • 20