Hi,
I have 2 buttons in 2 slots ('slot1' and 'slot2'). When removing button from slot1, the button in slot2 stops working (throws javascript error on click).
Here is my code:
GWT:
HTML code:
Can you please advice a solution?
thank you
I have 2 buttons in 2 slots ('slot1' and 'slot2'). When removing button from slot1, the button in slot2 stops working (throws javascript error on click).
Here is my code:
GWT:
Code:
package com.gwt.tableTest.client;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Window;
import com.smartgwt.client.widgets.events.ClickHandler;
import com.smartgwt.client.widgets.events.ClickEvent;
import com.smartgwt.client.widgets.Button;
public class Test implements EntryPoint {
static Button b = new Button("dynamic button");
public void onModuleLoad() {
addStaticButton();
addDynamicButton();
publishStaticMethods();
}
public static void addDynamicButton() {
b.addClickHandler(new ClickHandler(){
public void onClick(ClickEvent event) {
Window.alert("clicked on dynamic");
}
});
DOM.getElementById("slot1").appendChild(b.getElement());
}
private void addStaticButton(){
Button t = new Button("static button");
t.addClickHandler(new ClickHandler(){
public void onClick(ClickEvent event) {
Window.alert("clicked on static");
}
});
DOM.getElementById("slot2").appendChild(t.getElement());
}
public static void removeDynamicButton(){
DOM.getElementById("slot1").removeChild(b.getElement());
}
public static native void publishStaticMethods() /*-{
$wnd.removeButton = function(){
@com.gwt.tableTest.client.Test::removeDynamicButton()();
};
}-*/;
}
Code:
<html>
<head>
</head>
<body>
<div id="slot2"></div>
<div id="slot1"></div>
<script language="javascript" src="/webtools/tableTest/com.gwt.tableTest.Table.nocache.js"></script>
<button onclick="removeButton();">remove button from gwt</button>
</body>
</html>
thank you