On 03/21/2013 09:37 PM, Andy Stevko wrote:
I assume you see it loading facebook's all.js because you see it being
fetched and into the script element facebook-jssdk.
I think the problem is that facebook's js library assumes the DOM is
statically built, scans the document and enhances the proper elements
when loaded.
I once ran into a problem with the facebook scripts needing to be
retriggered so that they would rescan the DOM and modify elements added
dynamically.

After you add your like-box to the DOM, try calling the FB parse method
from within a JSNI wrapper

public  static  native  void  reparse(String  elementid)  /*-{

   FB.XFBML.parse(document.getElementById(elementid));

}-*/;




On Thu, Mar 21, 2013 at 1:09 AM, Xybek
<[email protected]
<mailto:[email protected]>> wrote:

    I have this script which I put on top of the GWT nocache.js

         <head>
             <script type="text/javascript" language="javascript">
                     (function(d, s, id) {
                       var js, fjs = d.getElementsByTagName(s)[0];
                       if (d.getElementById(id)) return;
                       js = d.createElement(s); js.id <http://js.id> = id;
                       js.src =
    "//connect.facebook.net/en_US/__all.js#xfbml=1
    <http://connect.facebook.net/en_US/all.js#xfbml=1>";
                       fjs.parentNode.insertBefore(__js, fjs);
                     }(document, 'script', 'facebook-jssdk'));
             </script>
                 <script type="text/javascript" language="javascript"
    src="app/app.nocache.js"></__script>
         </head>
         <body>
             <div id="fb-root"></div>
             <div id="rootPanel"></div>
         </body>

    And on one of the page of the my site (which I use Errai-UI)

    This is added on the gwt "page":

    HTMLPanel likebox = new HTMLPanel("<div class='fb-like-box'
      datahref='http://www.facebook.__com/platform
    <http://www.facebook.com/platform>' data-width='595'
    data-show-faces='true' data-stream='true' data-header='true'></div>");

    likepanel.add(likebox); // Add to the SimplePanel

    The problem I am facing is that in my GWT application, when the site
    lands on the "page" where this panel is injected, the Facebook like
    box doesn't get rendered, even if I look at the DOM, the `<div
    class='like-box' ...>` is there in the DOM tree.

    What works is that I need to do a full page refresh (in DevMode), on
    the currect page: example: `/mysite#PageWithFBDiv`

    Also, the page refresh trick only works in DevMode but fails to do
    the trick when compiled.

    --
    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
    [email protected]
    <mailto:google-web-toolkit%[email protected]>.
    To post to this group, send email to
    google-web-toolkit@__googlegroups.com
    <mailto:[email protected]>.
    Visit this group at
    http://groups.google.com/__group/google-web-toolkit?hl=en
    <http://groups.google.com/group/google-web-toolkit?hl=en>__.
    For more options, visit https://groups.google.com/__groups/opt_out
    <https://groups.google.com/groups/opt_out>.





--
-- A. Stevko
===========
"If everything seems under control, you're just not going fast enough."
M. Andretti




--
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
[email protected].
To post to this group, send email to
[email protected].
Visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.



Thanks, you have a point in your answer, however how where you able to make your reparse method work: I get:


Caused by: com.google.gwt.core.client.JavaScriptException: (ReferenceError): FB is not defined

When reparse() is called. Did you have to include additional JS library?

--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to