Tuesday, January 13, 2015

Re: Javascript is not attaching to the DOM

try the following:

@Override
protected void onLoad() {
super.onLoad();
dateComp(getElement());
}

public static native void dateComp(Element elem) /*-{

        $wnd.$(elem).datepicker({
            format: 'm/d/yyyy',
            showWeek: true,
            startDate: 'today',
            autoclose: true,
          });
 
}-*/;
On Tuesday, January 13, 2015 at 10:26:44 AM UTC+1, Yogish Nayak wrote:
Thanks for the reply... I tried with calling javascript function in onload method of widget... still the datepicker popup is not coming up.
Below is the code snippet which I have used...

@Override
protected void onLoad() {
super.onLoad();
dateComp();
}

public static native void dateComp() /*-{
 $( document ).ready(function() {
        $('.date').datepicker({
            format: 'm/d/yyyy',
            showWeek: true,
            startDate: 'today',
            autoclose: true,
          });
    });
}-*/;

Any ideas how to resolve this issue??

On Monday, January 12, 2015 at 5:50:44 PM UTC+5:30, Frank Taffelt wrote:
sounds like a timing problem. the jquery document ready listener fires before your date element is created and attached to the DOM. You could try to call your datepicker javascriptcode after your UIBinder based widget is created. Try overriding the widgets onLoad Method.


On Monday, January 12, 2015 at 10:33:50 AM UTC+1, Yogish Nayak wrote:
I have got one issue here. I am using bootstrap css and gwt in my application.
In my uibinder page, I am using gwt textbox, and applying a style ("date") as shown below.

    <g:TextBox styleName="span11 date"></g:TextBox>

Also bootstrap-datepicker.js and related bootstrap css files have been attached. On loading of a html, I am running the below script.

    $( document ).ready(function() {
        $('.date').datepicker({
            format: 'm/d/yyyy',
            showWeek: true,
            startDate: 'today',
            autoclose: true,
          });
    });

Still bootstrap datepicker popup is not coming on focus of a gwt textbox.

Also, I tried the otherway round, by injecting the js file and using JSNI approach.

Still it didn't worked.. 

Also, when I open the browser console (using F12), and paste the above javascript snippet, it works fine.

Is there any settings/configurations needs to be done? 

Is GWT is blocking the javascript execution??? 

Any suggestions would be appreciated!!!

Thanks

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