Hello,
I'm trying to get jquery to do some ui affects for me while using GWT. I have notifications that I add to a page that when clicked should disappear. Since there could be multiple notifications of the same type (warning, error, etc.) I'm trying to dynamically add a style name only when they are clicked through GWT and then have jquery act on that particular class name.
The problem is that the jquery function is firing before the style name can be added so the user has to click the notification twice in order for it to close.
Any ideas?
public abstract class AbstractNotificationWidget extends Composite implements ClickHandler, HasClickHandlers {
protected abstract String getUniqueId();
@Override
public HandlerRegistration addClickHandler(ClickHandler handler) {
return addDomHandler(handler, ClickEvent.getType());
}
@Override
public void onClick(ClickEvent event) {
doClick(getUniqueId());
}
protected static native void doClick(String name) /*-{
$wnd.$("#" + name).click(function () {
$wnd.$(this).slideUp("slow");
$wnd.$("div", this).fadeOut("slow");
});
}-*/;
}
I then have subclasses that extend the above class
public class ErrorNotificationWidget extends AbstractNotificationWidget {
private final String uniqueId;
public ErrorNotificationWidget (String title, String message) {
uniqueId = DOM.createUniqueId();
initWidget(uiBinder.createAndBindUi(this));
this.getElement().setId(uniqueId);
this.addClickHandler(this);
}
@Override
protected String getUniqueId() {
return this.uniqueId;
}
These subclasses use the UIBinder to determine how they should be drawn. Then these widgets get added to a panel to be displayed.