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?
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.