Tuesday, April 7, 2015

Re: Not Able to attach events on CellTable using native Javascript

Hi,

jquery works on DOM elements.  When you're attaching the celltable there is a render process that constructs the DOM. You should call jquery only when "all is done".
Usually, I use the scheduleDeferred method of Scheduler to do that.

Furthermore, you should take a look at GQuery, so you could do jquery in java code (no JSNI).

An example from my app :

Scheduler.get().scheduleDeferred(new ScheduledCommand() {
 
@Override
 
public void execute() {
   list
.getElement().appendChild(sortElement);
   gqCells
= $(list).find(".cellListEvenItem, .cellListOddItem");
   gqCells
.addClass(sortHandlerAppearance.css().sortedElement());
   gqCells
.each(new com.google.gwt.query.client.Function() {
   
...




Le mercredi 1 avril 2015 14:57:12 UTC+2, Ramesh a écrit :
Hi 
I am attaching events on cell table data using native javascript(jquery), but the events are not binding and what i have discovered is, If I use these along with setTimeout(..,10000) function, the events are binded and working properly.

This is the code i have used in UIBinder's java file.
       @Override
protected void onAttach() {
super.onAttach();
clearRequiredValidatorOnNew();
}
    
      $wnd.setTimeout(function() {
       $wnd.jQuery('.icon-pencil').click(function(e) {
if ($wnd.jQuery(this).text().trim() == ''){
$wnd.jQuery(this).closest('form').find('.reqField').each(function() {
$wnd.jQuery(this).css('background','transparent');
$wnd.jQuery(this).prev('label').removeClass('text-warning');
$wnd.jQuery(this).prev('label').children('span.reqIndic').css('visibility', 'hidden');
});
}
});
}, 1500);
Here the class .icon-pencil will reside in CellTable(data).

Please suggest how i can use this without timeout.

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment